I would recommend using the built-in cache instead of reinventing the wheel. It will automatically take care of such situations: the items expire, depending on their priority, if the memory starts to work at a low level. It is also very extensible, and you can easily distribute it among popular vendors such as memcached .
Please note that it System.Runtime.Cachingis only available in .NET 4.0. Other caches are available in earlier versions, such as the corporate library, System.Web.Caching, Velocity, ...
source
share