0

I have a c# app, which caches few data table in memory from sql server database. I have written a thread to update the cache after 30 minutes, but that does not sounds a good solution. I feel the best solution will be to expire cache on data table data change. Is there any framework that does this by configuration. I check Enterprise Cache Liberary but it does not seems to provide eye on data table. Do I have to write trigger in database that will update a table that will help my thread to look into it and decide to expire the cache.

Please let me know the best practice for this requirement.

Imran Rizvi
  • 7,331
  • 11
  • 57
  • 101

1 Answers1

0

You are probably looking for SqlDependency/SqlCacheDependency. Not very sure though. Check this link here. It might be of use to you.

Hope this helps.

samar
  • 5,021
  • 9
  • 47
  • 71
  • this looks good, as I had written a thread to monitor database, I need to compare performance between my implementation and SQLDependency, how frequently it looks for changes, does it fire the same command and compare data in memory? – Imran Rizvi Jan 27 '14 at 11:31
  • I don't think it looks for changes. In fact it notifies the client if there is a change in result for the registered query. – samar Jan 27 '14 at 11:41
  • Yes it looks for changes, SQL does not notify Applicaiton, SQLDependency internally looks for changes to the log table after a configured time. see http://stackoverflow.com/questions/7353558/how-does-a-sqlcachedependency-know-when-to-communicate-back-to-any-listeners-whe – Imran Rizvi Jan 27 '14 at 11:48