Question

So I am using AppFabric for Windows Server to be a distributed caching system which will have clusters to form a cache system.

One thing I was reading about in the documentation:

For best performance, only enable local cache for objects that change infrequently. Using local cache for frequently changing data may increase the chance that the client will be working with stale objects. Although you could lower the ttlValue and make a process refresh the local cache more frequently, the increased load on the cluster may outweigh the benefits of having the local cache. In such cases of frequently changing data, it is best to disable local cache and pull data directly from the cluster.

http://msdn.microsoft.com/en-us/library/hh351483(v=azure.10).aspx

Now, since my situation is that objects WILL be changing frequently, how would I access the cache directly rather than through the local cache? This part is not made clear or maybe I am misunderstanding here.

Is there an example of this?

Was it helpful?

Solution

You don't need to do any explicit coding work. The flow is as follows:

  1. you setup the AppFabric caching Server which has the Cache Clusters.
  2. Your client app uses the DataCache client to interact with this cache server.
  3. When you request data using the data cache client, it'll make a network call to the server and get the data. The server sends back the data over the wire and it is deserialized by the data cache client library and given to you.
  4. When you enable localcache in Data Cache config settings in the client app, what Data Cache Client does is that it keeps a reference of this deserialized object in your client app's memory.
  5. The next time you request the same data, it'll check in this in-process memory for the object and if found, not make the data cache server call. if not found, it'll repeat the process from #1.

so if the objects change/expire frequently, then just disable the local cache (since the overhead of syncing with server increases) and data cache client will always go to the server.

also when the data changes frequently and with local cache enabled, you run the risk of having stale data in your local cache, whereas other data cache clients may have updated the same object on the server.

the local cache is just an additional layer of performance benefits to be leveraged.

you can enable/disable it via code or config.

<localCache
  isEnabled="true"
  sync="TimeoutBased"
  objectCount="100000"
  ttlValue="300" />

Via code: http://msdn.microsoft.com/en-us/library/ee790857(v=azure.10).aspx Via config: http://msdn.microsoft.com/en-us/library/ee790880(v=azure.10).aspx

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