【发布时间】:2013-06-15 17:15:24
【问题描述】:
我在 MVC 和 Web API 应用程序中使用 MemoryCache 来缓存对象。我正在初始化 Global.asax.cs 中的缓存。
IE:
MemoryCache c = new MemoryCache(cacheNamespace);
var cacheItem = new CacheItem(key, value);
c.Add(cacheItem, cachePolicy);
但是,我想知道这个缓存什么时候被释放?当我重新启动我的应用程序时?这是假设我当然没有耗尽内存。
【问题讨论】:
-
简短回答:需要时。
-
@HenkHolterman 长答案是什么? :)
-
你是如何初始化缓存的?
-
@PrestonGuillot 更新了我的问题。我只是在实例化 MemoryCache,并向其中添加新项目。
标签: c# asp.net .net caching memorycache