How to clear MemoryCache?

Retrocoder picture Retrocoder · Nov 15, 2010 · Viewed 90.6k times · Source

I have created a cache using the MemoryCache class. I add some items to it but when I need to reload the cache I want to clear it first. What is the quickest way to do this? Should I loop through all the items and remove them one at a time or is there a better way?

Answer

GvS picture GvS · Nov 15, 2010

Dispose the existing MemoryCache and create a new MemoryCache object.