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,
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.NoSlidingExpirationis initialized toTimeSpan.Zero.Cache.NoAbsoluteExpirationis initialized toTimeSpan.MaxValue.