Timeout cache using .Net 4 and parallel collections

How to implement a cache class that supports timeouts using new .Net 4 concurrent collections?

A cache class typically contains hundreds of thousands of records. A very large part of the cache can expire at the same time.

Unlike a typical web cache, which may decrease due to memory pressure, this class should automatically delete objects if they time out.

+3
source share
2 answers

Why do you need to implement your own caching class? Isn't that a standard implementation? There's a whole new build designed for caching in .NET 4.0 . Example of caching a value for 10 minutes:

var cache = MemoryCache.Default;
cache.Add("key", new object(), DateTime.Now.AddMinutes(10));
+5
source

, . LRU . () (). , , -, O (1) . , , , . , .

. reset , ( ) ( ). LRU, . , , : . , , !

, LRU , , . , , .

+2

Source: https://habr.com/ru/post/1752218/


All Articles