0

According to MSDN , Cache set with sliding expiration gets expired if it hasn't been accessed within the specified time interval.

My question is will the Cache entry be removed immediately after the time interval has elapsed or is it removed when the next code statement tries to access it and the .Net realizes that it has expired ?

Chris Serrao
  • 135
  • 2
  • 12
abc cba
  • 2,563
  • 11
  • 29
  • 50

3 Answers3

1

Found the below for Caching from the link for Azure

There are three types of Expiration Type: None, Absolute, and Sliding Window. These configure how Time to Live (min) is used to determine expiration. The default Expiration Type is Absolute, which means that the countdown timer for an item's expiration begins when the item is placed into the cache. Once the specified amount of time has elapsed for an item, the item expires. If Sliding Window is specified, then the expiration countdown for an item is reset each time the item is accessed in the cache, and the item will not expire until the specified amount of time has elapsed since its last access. If None is specified, then Time to Live (min) must be set to 0, and items will not expire, and will remain valid as long as they are in the cache.

So, the expiration countdown will be reset if an item is accessed within the sliding window.

HCJ
  • 529
  • 1
  • 6
  • 14
0

The cache expiration time gets reset every time its accessed.

Black Frog
  • 11,595
  • 1
  • 35
  • 66
  • Are you mean that if the cache keep on getting access , it will not be expired , due to the expiration time keep refresh ? – abc cba Mar 10 '14 at 09:36
  • Yes, it will not expire until the specified amount of time has elapsed since its last access. – Black Frog Mar 10 '14 at 15:51
0

If it is accessed the the sliding expiration time will reset

SlidingExpiration will expire the entry if it hasn't been accessed in a set amount of time.

AbsoluteExpiration will expire the entry after a set amount of time.

You can use either. The ObjectCache Add() overload you're using treats it as an absolute expiration, so you'll need to use one of the other overloads

Refrence Answer

Community
  • 1
  • 1
  • This answer is amazingly similar to the accepted one in this post: [.NET Caching how does Sliding Expiration work?](http://stackoverflow.com/questions/13637856/net-caching-how-does-sliding-expiration-work). – scheien Mar 10 '14 at 09:40
  • @scheien it not similar, i have taken it from there only. – Vinay Pratap Singh Bhadauria Mar 10 '14 at 09:41
  • It was a joke. I see that it is a copy. You should credit the author, and not pass it on as your own. E.g a link to the original post. :-) – scheien Mar 10 '14 at 09:42
  • Isn't it he's asking when will the delete be triggered and not when will it expire, assuming no access has been done and it already reached expiration, will it be deleted immediately or it will stay there and wait for an access to know that it should has expired and have it deleted. – geno Mar 10 '14 at 09:51