notify local cache of change in the cache cluster
-
martes, 14 de febrero de 2012 0:05
I am using appfabric caching in my c# application. I have enabled local cache.
When I add, remove, update or delete an item from my cache cluster I would like to send a notification to the local that such has occurred via my c# code. Is this possible and if so how is it achieved?
I was considering setting it up on the web.config of my application to poll looking for updates to the cache cluster but I am concerned that this may have performance issues therefore I would like to include the trigger of the notification in my code.
Todas las respuestas
-
martes, 14 de febrero de 2012 5:29
Hi,
Did you mean programmatically setting up local cache with invalidation using notification ?
You can follow this link to setup local cache with notification .
http://msdn.microsoft.com/en-us/library/hh334204.aspx
Arun
arunks
-
martes, 14 de febrero de 2012 10:49
Local cache with notification is invalidation based means if any update is done to item in the cluster then the item is removed from the local cache.
And the next get operation will fetch from server and update the local cache.
You can register for specific notfications with custom callback routines. On periodic polling of notification, custom callbacks are called which can do any custom action other than updating the local cache.
Another thing to think about in terms of polling interval and subsequent thread activity on polling notifications from the cluster and the data getting transfered on the wire.
-
martes, 14 de febrero de 2012 13:06
One interesting solution is listed here where local cache is maintained in application data structure
http://social.msdn.microsoft.com/Forums/en-US/velocity/thread/5017d650-fb1c-4cca-8fd6-602703b2e253
Side effect of this approach is to implement get wrapper and maintaining the data structure.
-
martes, 14 de febrero de 2012 23:14
Thanks for all the information on this.
I am looking to go with a notification based invalidation of the local cache.
I would like to keep the local cache and cache cluster in relative sync state where changes in the cluster are reflected on the local cache as early as possible. Therefore I am looking at a polling rate of around 30 seconds. Performance wise, would this be performant or have a negative impact on performance? I would like to make the polling even shorter than this but I presume the shorter I make it the chances are I will run in to performance issues with the number of polling requests made.
-
jueves, 16 de febrero de 2012 9:24
If you mean performance of cache calls like get/put then there is no impact on these.
There are two part of local cache with notification in terms of impact analysis:
One is separate thread for send and receiving notification request to update local cache
and second is the data transfered on the wire for notifications.
Since polling and receiving threads are seaprate threads from your application thread the impact will be same as time slice sharing between multiple threads of an application which becomes less of concern with multi-core or multi-threaded core systems.
Amount of data on wire will be proportional to the amount of changes in server and PollInterval and since , the complete object is not transfered in case of local cache and only few meta data properties are transfered to invalidate the local cache, this should not lead to network bandwidth hit.
A sample load of your scenario will be able to guide you better in terms of setting correct PollInterval for your scenario.

