0

Below is the dataCacheClient entry in web.config:

<dataCacheClients>
  <dataCacheClient isCompressionEnabled="true" name="default">
    <autoDiscover isEnabled="true" identifier="MyRoleName" />
    <localCache isEnabled="true" sync="NotificationBased" objectCount="100" ttlValue="3000" />
    <clientNotification pollInterval="300" />
    <transportProperties maxBufferSize="1073741824" maxBufferPoolSize="1073741824" />
  </dataCacheClient>
</dataCacheClients>

The above configuration will use colocated caching on MyRoleName roles. In addition to colocated caching, I have indicated that I also want to use localCache. I am still a bit confused about this.

Please could someone validate my assumptions below:

  • Cached items will be stored, in addition to the colocated cache, in local RAM (localCache) on each role to improve cache read performance.
  • This local cache is "NotificationBased" meaning that it will perform a polling check with the colocated cache to check for changes every 300 seconds (pollInterval). If there is a difference, then the local cache will invalidate itself until the next colocated read.
  • In addition, the local cache will invalidate itself after 3000 seconds (ttlValue) which will force a refresh on the next colocated cache read.

In role cache settings I have the following configuration:

Role Cache Settings

  • This has nothing to do with local cache.
  • "Notifications" enabled means that the colocated cache won't time out.

Thanks

Dave New
  • 38,496
  • 59
  • 215
  • 394

2 Answers2

1

At first I also was a little confused with how localCache works with co-located caching. But as I realised localCache is required only for dedicated caching, when you have seperate caching server. In this case localCache reduces cache respose time, because it's also stored in all instances memory and is just being synchonized via notifications.

If you use co-located caching, cache is already stored in instances memory, so it's already localCache. It is automatically synchronized between all instances.

Similar like if you have multiple dedicated cache roles you don't have to synchronize data between them.

To be completeley sure I've made a simple test with Azure Emulator. I started it with two instances. And added object to cache at first instance, then checked if it exists at second instance, and it was there.

Dmitri Usanov
  • 348
  • 4
  • 11
  • As far as I understand, co-located caching should benefit from local caching if more than 1 instance is being used. This would be because although a cached object may reside in the co-located cache, it won't necessarily be on all the instances. This would require that objects be fetched by one instance from another. Local cache solves this problem. I may be wrong, but this is how I understand it? I also found [this post](http://social.technet.microsoft.com/Forums/windowsazure/en-US/fa4bcd6f-80aa-450b-8cc8-ecb309f69fb8/azure-caching?forum=windowsazuredevelopment) on the MSDN forums. – Dave New Jul 09 '14 at 14:10
  • Thanx for the post. That clarifies a lot. – Dmitri Usanov Jul 09 '14 at 21:08
1

Think of local cache as something only for the client. This will give you a clear perspective. You are maintaining a local copy at the client of the objects you frequently/recently use. Client could be anywhere - onPremise, in azure , even in a different deployment. In every x time interval you have mentioned in notification interval, it will poll the server or main cache and see if any notifications are available for objects within the local cache And yes, ttl value is the time to refresh the local cache

Alfan
  • 235
  • 2
  • 10