Search code examples
appfabric

AppFabric localcache


I am using AppFabric caching in one of my projects. I understand that the cache can be made available server only or it can have a local version as well (I assume this is done by instantiating the DataCacheLocalCacheProperties class and assign this to the DataCacheFactoryConfiguration's properties) - please correct me if I am wrong. I also assume that if a Get is done when a localcache is enabled, the object will be retrieved from the cache server if it is not available locally.

But, what is the case of a Put? When I have a localcache enabled, a Put that I do will update the cache server for the specified key? If yes, then how will this value be reflected in the localcache? Or, it just updates the localcache?

Thanks in advance!


Solution

  • Joeseph,

    Yes you can use local cache to store objects in-memory at the client. Local caching is generally used to stored objects that don't change frequently. The helps with the latency costs associated with the round trip to the cache server(s).

    Now coming back to your questions:-

    1- You can initiate local client cache with xml configuration as well. http://msdn.microsoft.com/en-us/library/ee790880.aspx

    2- When you do a Get if the cache item is not available in the local cache then it is fetched from the Cache Server(s).

    3- Put always goes to the Cache Server(s).

    4- Local Cache has "sync" properties that allow it to be synced with the server cache either through a) a 'timeout' value (such that once the ttl expires the object will be updated based on the server cache) or b) Cache notifications (such that the clients are notified everytime the cache is updated on the sever) - visit http://msdn.microsoft.com/en-us/library/ee808091.aspx for more details.

    HTH.

    cheers, //hr/

    http://www.hammadrajjoub.net