Does C # have a collection that works like a cache?

Search for a dictionary or the like that automatically deletes entries after a certain amount of time, either if they are not used for X time or are simply deleted after X time, regardless of use.

Before I abandon my own, I was wondering if C # had this feature in one of its collections. I did not see anything on google, but I wanted to check.

+4
source share
2 answers

You can find MemoryCachefrom System.Runtime.Caching. Although it is not generic (if you use value types, it might be something to consider), it does have the TTL mechanism you are looking for.

+8
+1

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


All Articles