I have found an answer to a similar question (System.Web.Caching.Cache.NoSlidingExpiration in asp.net c#) and followed the links, but I need more specific information I cannot find.
NoSlidingExpiration does not reset when you 'access' it. But, does that mean when you read it? Or also when you write it?
For example, if I do
Cache.Insert("mykey", 42, null, DateTime.Now.AddMinutes(20), System.Web.Caching.Cache.NoSlidingExpiration);
and then 10 minutes later, I do:
Cache.Insert("mykey", 42, null, DateTime.Now.AddMinutes(20), System.Web.Caching.Cache.NoSlidingExpiration);
again开发者_如何学编程, will the expiry be adjusted?
Thanks!
According to the MSDN doc on Cache.NoSlidingExpiration
When used, this field sets the slidingExpiration parameter to the TimeSpan.Zero field, which has a constant value of zero. The cached item expires in accordance with the absoluteExpiration parameter associated with the Insert or Add method call.
That means when you call Add
or Insert
, whatever the absoluteExpiration
value you have given in that call will be used to expire that item. So in your example:
DateTime.Now.AddMinutes(20)
means the item will be reset after 20 minutes.
精彩评论