开发者

Microsoft Enterprise Library Cache Key wildcard search

开发者 https://www.devze.com 2023-04-11 17:15 出处:网络
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

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

  1. Is there a way to search for keys in the Enterprise Library Framework?
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号