Correct me if I'm wrong.
The ICacheItemExpiration
(in our case) that we specify in the Add()
method actually defines the expiration policy that will be applied to that item being added to the cache. In our case, we have use SlidingTime
expiration policy. Suppose we set the SlidingTime
to 10 seconds. What is implied is that the item will be flag as expired if it is not accessed continuously for 10 second. This is useful when we need to keep the item alive when there are multiple request coming in for that item. As a side note, we have other expiration policy such as AbsoluteTime
, FileDependency
, NeverExpire
...
We need to understand that when an item has been expired, it is still present in the hash, until a background scheduler remove that item (depending on its expiration policy that the background scheduler will check for expiration). When setting a value for expirationPollFrequencyInSeconds
, we are defining the time interval for the background scheduler to execute and analyse the hash to remove items that have been expired (according to the expiration policy defined on that item).