_cache.Insert(cacheKey, userList, null,
Cache.NoAbsoluteExpiration,
new TimeSpan(0, 15, 0),
CacheItemPriority.High, null);
My code above doesn't seem to be expiring the cache after 3 minutes, the userList object pulls data from the database that was updated, but the cache doesn't expire it after 15 minutes.
What is wrong?
You are explicitly setting the cache to never expire by using Cache.NoAbsoluteExpiration
. You want to use Cache.NoSlidingExpiration
instead:
When used, this field sets the
slidingExpiration
parameter to theTimeSpan.Zero
field, which has a constant value of zero. The cached item expires in accordance with theabsoluteExpiration
parameter associated with theInsert
orAdd
method call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With