Microsoft Enterprise Library Cache Key wildcard search
I use Enterprise library caching application block. The specifics of our requirements required me to add dynamic keys into the cache that depend on different parameters. The keys also have a prefix to group them easily. For example:
AccountsStaffMark1234
AccountsStaffPeter0123
AccountsStaffHenry1111
ScienceStaffRuth2222
EnglishStaffSimon3333
I need to be able to search for all AccountsStaff cache开发者_StackOverflow中文版 entries and remove them when fresh data is available.
I cannot use the Flush()
keyword as it clears all the data, including Science
and English
. The cached data is stored in a caching DB and I can make wildcard queries on the CacheData
table to filter AccountsStaff
. Along these lines
- Is there a way to search for keys in the Enterprise Library Framework?
- If not, is it possible to extend the caching library for my requirement, and how?
Ok, figured one way out.
Cache
object exposes the Hashtable with all the keys stored in it. I will build custom logic around the keys to remove specific instances.
So, in the above case, search for all keys starting with AccountsStaff
and remove them explictly.
精彩评论