Question

I understand that regions in Azure caches provide a different way to access objects in the cache (other than using the key).

However, I'm wondering why there is a version of DataCache.GetAndLock() that accepts both the key and the region.

Isn't the key enough to identify the object in the cache? Or can I have objects with the same key in the different regions (in the same DataCache)?

What happens if I add an object to a certain region and then try to get it without specifying the region (but only the key)?

Was it helpful?

Solution

A key defines an object within a region.

Regions exist as a mechanism for specifying that similar data should be stored on the same cache server. This allows you to leverage the cache calls that search the cache and return a set of objects. Without the guarantee that regions provide, these queries may have to fan out to multiple cache servers.

If you insert an object using the overload that does not specify the region, you must similarly access it using the method overloads that do not specify a region. These objects are stored in the default cache and there is no guarantee that they reside on a single cache server.

On the contrary, if you need to use the tagging and searching options of the cache, you should be inserting your objects into a specific region and using the corresponding Get operations that specify a region as well.

OTHER TIPS

To correct your assumption : Using region is not another way to access cache object other than key. Regions is for bifurcation of type of objects being put in cache. It is a logical entity. Like a shopping cart. If you want to put items related to electronics in one bucket, you put them in 'electronics' region but all the objects you put in that bucket will have it's own keys. You will access/retrieve the object using both key and region.. So if you have put an object into a particular region and you want a lock handle for that object, you use the lock handle with both key and region parameters. Othervise you use the one with just key parameter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top