Default duration of Cache.Insert in ASP.NET

前端 未结 2 1669
逝去的感伤
逝去的感伤 2021-02-19 18:43

If I have the following line, when should I expect the cache to expire?

System.Web.HttpRuntime.Cache.Insert(\"someKey\", \"Test value\");
2条回答
  •  面向向阳花
    2021-02-19 18:48

    This will insert the object without an explicit expiration set. This means the object will not automatically be removed from the cache, unless the runtime decides to remove stuff from the cache due to high memory usage.

    Calling this overload is the same as calling

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

    BTW: you can use .NET reflector to find out such things.

提交回复
热议问题