Reputation: 549
My web application is using the asp.net cache object to store data from the database. I am looking for an elegant to invalidate cache objects but haven't come up with anything elegant yet.
It is easy to invalidate a single record or a list of all records in a single table, by keeping track of their cache keys. However I may have any number of lists of subsets of a table's data. I would like to invalidate only the cache records of the lists that contain a particular record, when that record changes. I don't want to have to invalidate all the lists of data for that table if only one of the lists contain that record.
I have tried SqlDependency and not happy with it as I've run into a lot of issues. Do you have any idea how to attack this problem? Thanks in advance!
Upvotes: 1
Views: 1675
Reputation: 11454
create a static Dictionary<string, List<string>>
the key will use a naming scheme like table_primarykey which represents a single record
the value is a list of cache key names that the record is cached in
this will let you effectively find what records are cached where, permitting that you manage the dictionary while adding and removing items (use a callback) from the cache.
Upvotes: 1