.Net MemoryCache - How to update the expiration time for an existing item?

The Memcached API has a Touch () method that updates the expiration policy for a given key. What is the best way to accomplish this with the .Net ObjectCache class?

The best I could see was to remove the object and re-add with a new expiration, but obviously this would be optimal performance.

+4
source share
1 answer

Unfortunately, it is not possible to reset the duration of the item cache.

However, since it is a cache in memory (not distributed like memcached), get and re-add are fast, like link passing.

Another option is to use SlidingExpiration for your cache item.

+5
source

All Articles