Custom MemoryCache lifetime management

Tbdvltqliznva

New Member
I want to use a custom memorycache in my ASP.NET app, so that each different Type has a different cache. This cache should behave as an Application cache.\[code\]public class AuthTokenCache: MemoryCache{ public AuthTokenCache() : base("AuthTokenCache") { }}\[/code\]How do you manage the lifetime of these cache objects? If I use MemoryCache.Default then I don't have to think about it, but how/where do I create my CustomCache? Does this need to be used in tandem with an IoC such as Spring, and then it creates it as a Singleton? Will that be thread-safe?ThanksDuncanPS I really don't follow the example given here - http://blogs.msdn.com/b/aspnetue/ar...-cache-objects-in-an-asp-net-application.aspx . In the page, the author creates the cache ("In the class declaration, add the following code to instantiate the custom cache. You must create and keep the reference of the custom cache to prevent it from going out of scope.") - but this will be created every time the page is created and is not what I want (an Application-wide cache) !
 
Back
Top