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 do it is like so:
foreach (DictionaryEntry CachedItem in Cache)
{
string CacheKey = CachedItem.Key.ToString();
if(CacheKey.StartsWith(CACHE_PREFIX){
Cache.Remove(CacheKey);
}
}
Could I be doing this more efficiently?
I had considered creating a temp file and adding the items with a dependancy on the file, then just deleting the file. Is that over kill?