Removing specific items from Cache (ASP.NET)

前端 未结 5 790
执念已碎
执念已碎 2021-02-14 02:07

I am adding a bunch of items to the ASP.NET cache with a specific prefix. I\'d like to be able to iterate over the cache and remove those items.

The way I\'ve tried to d

5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-14 02:19

    You should keep another item in cache for this purpose only. Let's say you cache 10.000 items with keys like: cache_prefix_XXX. So adding an item with just cache_prefix as its key and adding the rest of them with a dependency on this key you can control the removal of all of them. One thing to consider would be the priorities. Set that particular item a higher priority than the actual data items.

提交回复
热议问题