Reputation: 2633
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 ?
Upvotes: 0
Views: 1197
Reputation: 9947
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
Upvotes: 0
Reputation: 527
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.
Upvotes: 1