public class MemoryCacheHelper
{
private static CacheManager _Cache = null;
static MemoryCacheHelper()
{
IBackingStore backStore = new NullBackingStore();
ICachingInstrumentationProvider instrumentationProvider = new CachingInstrumentationProvider("MemoryCacheHelper", true, false, "MemoryCacheHelper");
Cache cache = new Microsoft.Practices.EnterpriseLibrary.Caching.Cache(backStore, instrumentationProvider);
ExpirationTask eT = new ExpirationTask(cache, instrumentationProvider);
ScavengerTask sT = new ScavengerTask(10, 1000, cache, instrumentationProvider);
BackgroundScheduler bS = new BackgroundScheduler(eT, sT, instrumentationProvider);
ExpirationPollTimer ePT = new ExpirationPollTimer(60 * 1000);
_Cache = new CacheManager(cache, bS, ePT);
}
public static CacheManager Cache
{
get
{
return _Cache;
}
}
}
有时会有这样需求的,作为一个备份放在这儿吧。