locked
Windows Azure Cache - retrieve all named regions RRS feed

  • Question

  • Hi all,

    I created regions in the default cache. Let's assume one of the regions was named "xyz". When I use GetSystemRegions, I don't get the "xyz" region back, I get a list of default regions. I don't get the region named "xyz". Is there a way to get that out?

    DataCache testCache = new DataCache("default");
    testCache.CreateRegion("xyz");

    IEnumerable<string> cacheRegions = testCache.GetSystemRegions();

    foreach (var item in cacheRegions)
    {
     Console.WriteLine(item);
    }




    Sunday, April 20, 2014 1:06 AM

All replies

  • Hi,

    Firstly, please make sure you used azure In-Role cache not azure sharing cache . Because Sharing cache didn't support this method (http://msdn.microsoft.com/library/azure/gg278350.aspx ),see this case (http://stackoverflow.com/questions/11179429/azure-createregion-this-operation-is-not-supported-by-the-cache ).

    Secondly, It seems like your code is right. I suggest you could try to store the data into regions and try to retrieve it again. Like this:

    //store data into cache
    DataCache dc = new DataCache(“default”);
    dc.CreateRegion(“xyz”);
    dc.Put(
    “itemKey1”,
    “Iris”,
    new List<DataCacheTag>()
    {
           new DataCacheTag(“music”),
           new DataCacheTag(“europe”),
    
    },
    “xyz”);
    dc.Put(
    “itemKey2”,
    “Microsoft”,
    new List<DataCacheTag>()
    {
           new DataCacheTag(“IT Company”),
           new DataCacheTag(“europe”),
    
    },
    “xyz”);
    //retrieve data 
    foreach (string region in dc.GetSystemRegions())
        {
            foreach (var item in dc.GetObjectsInRegion(region))
            {
                Console.WriteLine("data item ('{0}','{1}') in region {2} of cache {3}", item.Key, item.Value.ToString(), region, "default");
            }
        }
    
    Also, I suggest you could refer to this code sample from (http://stackoverflow.com/questions/17546240/how-to-read-all-the-items-present-in-an-appfabric-cache )

    Please try it.

    Regards,

    Will


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 21, 2014 7:21 AM
  • Hi Will,

    Here is some background information about the cache I am using. I am using Cache (Preview) which has three offerings : Basic, Standard and Premium. I created a cache of 1 GB using the Standard offering in Cache (Preview). http://msdn.microsoft.com/en-us/library/dn386114.aspx 

    I used the code that you have listed in  your email, but it did not return the inserted items. While debugging, the regions iterate from Default_Region_0000 through Default_Region_0059. At the same time, it does not throw any errors.

    I am a bit confused here. I went through your links. The link http://blogs.msdn.com/b/avkashchauhan/archive/2012/06/18/difference-between-windows-azure-cache-preview-and-windows-azure-share-cache.aspx it has a section "Windows Azure Cache (Dedicated and Co-located) Preview:"

    Since I am using the Cache Preview, I am not sure if I am using dedicated or shared caching? The way I am testing / using the cache is by creating the 1 GB Standard offering through cache (preview), followed by creating a console app, pointing to the cache using app.config settings and using the methods. Based on the information provided, I am not sure what flavor of Azure caching I am using. Shared / Not Shared? Dedicated / Co-located? it will be great if you can clarify.

    Thanks


    Monday, April 21, 2014 3:56 PM