"Default" DefaultCacheManager expiration?

Topics: Writing modules
Mar 26, 2012 at 9:16 PM
Edited Mar 26, 2012 at 9:17 PM

Suppose one were to use an injected ICacheManager in their module, to cache some infrequently-changing data. 

And suppose one were to call the .Get method of the ICacheManager, and not call the AcquireContext.Monitor action to force an expiration at any point.

How long would that item be cached? Until the app pool recycles? Or, is there some default cache duration through the DefaultCacheManager, which would expire sooner? 

In other words, my code looks like this -- 

 

    var cacheItems = _cacheManager.Get("Products_Brands", ctx =>
    {
	//notice, no reference to ctx.Monitor...
        return _repository.Table.OrderBy(x => x.Name).ToList();
    });

At what point can I expect cacheItems to contain refreshed data?

Coordinator
Mar 27, 2012 at 6:46 AM

You can't really know. It can happen because of memory pressure, appdomain restart, who knows? Why do you care? And why don't you want to make it expire?

Mar 27, 2012 at 3:58 PM

Yeah, it's not so much that I don't want it to expire, as I was trying to figure out why some data WASN'T expiring. I was really just looking to confirm my suspicion that it was not expiring because I never asked it to, and that sounds like it is definitely the case. 

This is absolutely my fault for writing code before I understood what it was doing...I think I just assumed that it would expire after some default amount of time even if I didn't explicitly tell it to. A poor assumption, I realize in retrospect. 

Thanks as always!