0

I am working with a large web application where there can be up to 100,000 objects, populated from a DB, in cache.

There is a table in the database which, given the object ID, will give you a last_updated value which is updated whenever any aspect of that object changes in the DB.

I have read creating an SqlCacheDependency (one row in a table per object) per object, which such high number of objects is a no-go.

I am looking for alternative solutions. One such possible solution I thought of is to cache the "last_updated" table as a datastructure and create a cache dependency to the table it is based on. Then whenever one of the 100,000 objects is requested, I check the cached "last_updated" table and if it is out of date, I fetch the object again from the database and re-cache it. If it is not out of date, I give the cached version. Does this seem like a reasonable solution?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – John Saunders Jul 16 '13 at 19:05

1 Answers1

0

But.. how you can do it for a single row of the table.. In ASP.Net you can create SQl Server dependency which uses a broker Service.. and puts the data into the cache and whenever the table is updated.. the cache will be rejected and new data is taken from db and put into the cache..

i Hope this might give you some idea!

Prateek Dhuper
  • 51
  • 1
  • 1
  • 7
  • I believe you can also do row dependency, it just depends on your query. If your query selects a single row with a where clause, the cache dependency will only be for that one row versus the whole table. see: http://stackoverflow.com/questions/940418/how-do-i-create-a-row-specific-sql-cache-dependency – user1411140 Jul 16 '13 at 19:37