abc cba
abc cba

Reputation: 2633

what happen to sliding expiration after it accessed

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

Answers (3)

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

Upvotes: 0

HCJ
HCJ

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

Black Frog
Black Frog

Reputation: 11725

The cache expiration time gets reset every time its accessed.

Upvotes: 0

Related Questions