C# · Method · ASP.net
Cache insert with an absolute expiration
C# code to store an object in ASP.NET's server-side cache until a specific clock time expires.
How to use Cache insert with an absolute expiration:
Paste the code into the class or page, then call it from the method that needs the result.Absolute expiration expires at a fixed time. Sliding expiration resets each time the value is read. The cache is wiped when the app pool restarts.// using System.Web;
// using System.Web.Caching;
HttpRuntime.Cache.Insert(
"item-list",
value,
null,
DateTime.UtcNow.AddMinutes(10),
Cache.NoSlidingExpiration);