Azure DataCache and Regions

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

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

Is it not enough key to define an object in the cache? Or can I have objects with the same key in different regions (in the same DataCache)?

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

+4
source share
2 answers

A key identifies an object within an area .

Regions exist as a mechanism to indicate that such data should be stored on the same cache server. This allows you to use cache calls that look for the cache and return a set of objects. Without the guarantee provided by the regions, these requests may need to be deployed to multiple cache servers.

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

Conversely, if you need to use tags and search parameters in the cache, you must insert your objects in a specific region and use the corresponding Get operations, which also define the region.

+1
source

To correct your assumption: using a region is no other way to access the cache than the key. Regions are a bifurcation of the type of objects that are cached. This is a logical entity. Like a shopping basket. If you want to put electronics-related items in one bucket, you will put them in the β€œelectronics” area, but all the objects that you put in this bucket will have their own keys. You will receive / retrieve an object using both the key and the region. Therefore, if you placed an object in a specific region and you need a lock handle for that object, you use a lock handle with key and region parameters. Othervise you use one that has only a key parameter

-1
source

Source: https://habr.com/ru/post/1487328/


All Articles