David
David

Reputation: 1293

AppFabric Regions and Local Cache

(1) I'm wondering if I use Regions in my AppFabric Caching is it possible for the Regions to exist on the local cache? Or do regions only exist on the cluster?

(2) As a separate question how can I tell if my data is coming from the Cluster or from my local cache? Is there some kind of AppFabric tool that I can use to analyse where the data is coming from?

I am using configuration in code to set up my local cache properties to put my items in to local cache like so

localCacheConfig = new DataCacheLocalCacheProperties(10000, localTimeout, DataCacheLocalCacheInvalidationPolicy.TimeoutBased);

// Setup the DataCacheFactory configuration.
DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration();
factoryConfig.Servers = servers;
factoryConfig.LocalCacheProperties = localCacheConfig;

//code to put items in cache....etc

Do I need to do anything special on the 'Get' or is it smart enough to get it from local cache if it exists there?

Upvotes: 1

Views: 2494

Answers (3)

praveen
praveen

Reputation: 21

1.Regions do not exist in local cache, regions are specific to cache cluster only.

2.You can get statistics of a particular named cache by executing the below command in Appfabric powershell console,

get-cachestatistics <CacheName>

It gives you a result set which has ReadRequestCount, if a request goes to local cache this count will not increase for the particular request.

By this way you can check the local cache working.

Upvotes: 1

Cybermaxs
Cybermaxs

Reputation: 24556

Region is a logical concept in AppFabric. It will allow you to query items by tag, but items will be stored in only one host (limited distribution and high availability too).

Local cache is not bound to region. it's just a local copy of your latest call to the cache cluster. Local cache is enabled on client side, meaning that you can avoid it if you want.

The lifetime of an object in the local cache is dependent on several factors, such as the maximum number of objects in the local cache and the invalidation policy (timeout or notification).

You cannot know is data is coming from local cache or distributed cache. That's why local cache is recommended for reference data.

Upvotes: 2

PhilPursglove
PhilPursglove

Reputation: 12589

Regions can't exist in a local cache, they only exist inside a cache on the cluster.

Because local cache is optional, client code should be completely agnostic about whether a cached item is coming from the cluster or from the local cache. To enable that, when a requested item is in the local cache it will be returned from there (avoiding a cross-server call to the cluster).

Upvotes: 0

Related Questions