AdrianD
AdrianD

Reputation: 279

EntityFramework-Plus and ASP.NET Memory Cache expiration

i am using EntityFramework-Plus to add Second level caching to an ASP.NET web forms / WebAPI application.

This will add cache items into the memory cache. All good and dandy so far. The problem is that my items are stored for very little time in the cache.

I can not find any information on the default values of the cache expiration, I want to have them stored as long as the server will have memory for it :)

How can I extend this properly for the entire application? How can I find out when the items will expire? And what other server limitations I might have related to this?

Any help will be highly appreciated, thank you

Upvotes: 0

Views: 846

Answers (1)

Ricardo Peres
Ricardo Peres

Reputation: 14555

See the QueryCacheManager static class and set one of the DefaultCacheItemPolicy's members to the time you want.

For example:

var options = new CacheItemPolicy() { SlidingExpiration = TimeSpan.FromHours(2)};
QueryCacheManager.DefaultCacheItemPolicy = options;

See https://github.com/zzzprojects/EntityFramework-Plus/wiki/EF-Query-Cache-%7C-Entity-Framework-Second-Level-Caching.

Upvotes: 3

Related Questions