1

Is it possible to have 'Cache Dependencies' in AppFabric, or any other distributed cache system, similar to what you can do using the HttpRuntime cache of ASP.Net, using the CacheDependency class?

The scope of this is to have say a UserControl attached to a 'key' of the cache. If the cache entry changes, the usercontrol is invalidated and re-loads itself. Is this possible?

Karl Cassar
  • 6,043
  • 10
  • 47
  • 84
  • possible duplicate http://stackoverflow.com/questions/9298233/sqlcachedependency-and-appfabric-server – Cybermaxs Nov 05 '12 at 09:59
  • @Cybermaxs Although it looks like a duplicate, the selected Answer is actually a bit misleading. From the time I posted this question, I've researched a lot in the topic and this does have a solution via AppFabric Cache notification callbacks, which are a recent addition to this technology. I'll post this an answer here for other user's future reference. – Karl Cassar Nov 05 '12 at 10:06

1 Answers1

1

After some research and testing - AppFabric does support something similar to the above, which are called 'Cache Notification Callbacks'. Basicaly, you can attach to items/regions of the cache, and the system will raise events when the cache is changed.

However such notifications are not instant, and use a 'polling' mechanism. This is something which one must keep in mind, as at first I was thinking that the system is not working. The default polling is 300seconds (5 minutes), so it might take some "time" to get the notification. This can be changed to any other interval, and especially for testing.

I've tried this out and can confirm its working. Details on how to implement can be found on the MSDN link: http://msdn.microsoft.com/en-us/library/ee808091(v=azure.10).aspx

Karl Cassar
  • 6,043
  • 10
  • 47
  • 84
  • 1
    But the appfabric cache notification callbacks are not same as Asp.net Http Runtime cache using the CacheDependency class. Using cachedependency, you can list dependencies for your cached item and when any of those dependencies will get expired then your cached item will also get expired but that is not the case with appfabric callback notification. In appfabric, you get notifications only for your cached item and there is no out-of-box support for listing dependencies – Mandeep Janjua Apr 17 '14 at 00:49