Adding Items with a Sliding Expiration Policy
When you specify a sliding expiration policy, items remain in the cache just as long as they continue to be requested within a specified interval of time. For example, if you specify a sliding expiration policy of 5 minutes, the item remains in the Cache just as long as no more than 5 minutes pass without the item being requested.
Using a sliding expiration policy makes sense when you have too many items to add to the cache. A sliding expiration policy keeps the most requested items in memory and the remaining items are dropped from memory automatically.
The page in Listing 29.37 illustrates how you can add a DataSet to the cache with a sliding expiration policy of 5 minutes.
Listing 29.37. ShowSlidingExpiration.aspx ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access