ASP.NET中Cache.Insert的默认持续时间

Lar*_*nal 11 asp.net caching web-config

如果我有以下行,我什么时候应该期望缓存过期?

System.Web.HttpRuntime.Cache.Insert("someKey", "Test value");
Run Code Online (Sandbox Code Playgroud)

rea*_*idt 16

"从不",也就是说,只要内存不足,ASP.NET Cache认为它有更重要的东西要保留.


M4N*_*M4N 8

这将插入没有显式到期集的对象.这意味着该对象不会自动从缓存中删除,除非运行时由于内存使用率过高而决定从缓存中删除内容.

调用此重载与调用相同

Cache.Insert(
  key, value,
  null,                     /*CacheDependency*/
  NoAbsoluteExpiration,     /*absoluteExpiration*/
  NoSlidingExpiration,      /*slidingExpiratioin*/
  CacheItemPriority.Normal, /*priority*/
  null                      /*onRemoveCallback*/
);
Run Code Online (Sandbox Code Playgroud)

顺便说一句:您可以使用.NET反射器来找出这些东西.