开发者

What happens when I add item to Cache with TimeSpan.Zero as Expiration?

In my web services app, I found code that adds an item to the Cache:

System.Web.Caching.Cache.Insert(cacheKey, item, null, Cache.NoAbsoluteExpiration, 
          开发者_如何学Go                  TimeSpan.Zero, CacheItemPriority.Normal, callback);

In this case, it seems that there is no absolute expiration and the SlidingExpiration is being set to TimeSpan.Zero, which to me means that the items should expire immediately.

At the same time, I've never actually seen anything expire, but also, I am not patient enough to sit there and wait.

So what happens in this case? Is there some default that kicks in when SlidingExpiration is zero? Or does it never expire


This is equal to passing Cache.NoSlidingExpiration, so yes, the item will never expire (except due to low amount of available memory).

The static member Cache.NoSlidingExpiration is initialized to TimeSpan.Zero. Cache.NoAbsoluteExpiration is initialized to TimeSpan.MaxValue.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜