开发者

Pre .NET 4 memory cache

开发者 https://www.devze.com 2023-04-06 07:41 出处:网络
I want to use the new MemoryCache class but I am not yet using .NET 4. I do have a simple cache class (internally uses a dictionary). What would be a good approach in using 开发者_开发百科this class l

I want to use the new MemoryCache class but I am not yet using .NET 4. I do have a simple cache class (internally uses a dictionary). What would be a good approach in using 开发者_开发百科this class like the MemoryCache? Does anyone know how MemoryCache is managed throughout the lifetime of an application (non asp.net)?


Maybe you can use a tool like Structuremap for that? It's not really meant to do these things (it's a DI container) but it will work out well if you specify some items as a singleton, some items on a request basis etc. It just depends on how granular you want the lifetime management to be.


Enterprise Library had a Caching block that was similar to what .Net 4 has now on the core framework.

It was there for Version 5, but I think it has been removed from version 6. Getting an older version of the enterprise library will provide you with a caching mechanism.

0

精彩评论

暂无评论...
验证码 换一张
取 消