locked
How to Know Caching functionality working proces in windows azure? RRS feed

  • Question

  • Hi Experts,

    I deployed my asp.net mvc application in windows azure with Colocated caching.but am not able get caching working or not in my application.

    Can any one suggest me how to know the caching functionality in windows azure Cloud Service application.

    Thanks,

    PCSSCP.

    Saturday, March 2, 2013 5:25 AM

Answers

  • Hi PCSSCP,

    I recommend you read this on How to Use Windows Azure Caching, in particular the part of Working with Caches.

    using Microsoft.ApplicationServer.Caching;
    
    (...)
    
    DataCache cache = new DataCache("default");
    
    
    // Cache client configured by settings in application configuration file.
    DataCacheFactory cacheFactory = new DataCacheFactory();
    DataCache cache = cacheFactory.GetDefaultCache();
    // Or DataCache cache = cacheFactory.GetCache("MyCache");
    // cache can now be used to add and retrieve items.
    
    
    // Add the string "value" to the cache, keyed by "item"
    cache.Add("item", "value");
    
    
    // Add the string "value" to the cache, keyed by "key"
    object result = cache.Get("Item");
    if (result == null)
    {
        // "Item" not in cache. Obtain it from specified data source
        // and add it.
        string value = GetItemValue(...);
        cache.Add("item", value);
    }
    else
    {
        // "Item" is in cache, cast result to correct type.
    }
    
    
    // Add the string "value" to the cache, keyed by "item". If it exists,
    // replace it.
    cache.Put("item", "value");


    Best Regards,
    Carlos Sardo

    Sunday, March 3, 2013 8:21 PM

All replies

  • Hi,

    It's better to explain with more details,I mean what changes you did for enabled the caching for your application.

    Coming to to your question, what you want know is Caching working on your application or not.I am also not perfect on this .i think it's better to check your application performance now.

    Saturday, March 2, 2013 6:30 AM
  • Hi PCSSCP,

    I recommend you read this on How to Use Windows Azure Caching, in particular the part of Working with Caches.

    using Microsoft.ApplicationServer.Caching;
    
    (...)
    
    DataCache cache = new DataCache("default");
    
    
    // Cache client configured by settings in application configuration file.
    DataCacheFactory cacheFactory = new DataCacheFactory();
    DataCache cache = cacheFactory.GetDefaultCache();
    // Or DataCache cache = cacheFactory.GetCache("MyCache");
    // cache can now be used to add and retrieve items.
    
    
    // Add the string "value" to the cache, keyed by "item"
    cache.Add("item", "value");
    
    
    // Add the string "value" to the cache, keyed by "key"
    object result = cache.Get("Item");
    if (result == null)
    {
        // "Item" not in cache. Obtain it from specified data source
        // and add it.
        string value = GetItemValue(...);
        cache.Add("item", value);
    }
    else
    {
        // "Item" is in cache, cast result to correct type.
    }
    
    
    // Add the string "value" to the cache, keyed by "item". If it exists,
    // replace it.
    cache.Put("item", "value");


    Best Regards,
    Carlos Sardo

    Sunday, March 3, 2013 8:21 PM