Skip to main content

Cache Implementation in .NET 4.8

Published 1 min readMarkdown
Cache Implementation in .NET 4.8
if (Cache["total_"+ userId] == null)
{
    /* 30 minutes cache*/
    Cache.Insert("total_" + userId
        , dc.Customers.Where(p => p.UserId == userId).Count()
        , null, DateTime.Now.AddMinutes(30), TimeSpan.Zero);
}
total = (int) Cache["total_" + userId];

Reference :

https://learn.microsoft.com/en-us/dotnet/api/system.web.caching.cache.insert?view=netframework-4.8.1

About the author

No comments yet. Be the first to comment.

More from this blog