private static CommonCacheBase GetCacheProvider(CommonCacheStore store) { lock (_syncLock) { switch (store) { case CommonCacheStore.HttpCache: { if (_httpCacheObjectCache == null) { _httpCacheObjectCache = new HttpCacheObjectCache(); } return(_httpCacheObjectCache); } case CommonCacheStore.Memory: { if (_memoryObjectCache == null) { _memoryObjectCache = new MemoryObjectCache(); } return(_memoryObjectCache); } case CommonCacheStore.Request: { if (_requestObjectCache == null) { _requestObjectCache = new RequestObjectCache(); } return(_requestObjectCache); } case CommonCacheStore.Session: { if (_sessionObjectCache == null) { _sessionObjectCache = new SessionObjectCache(); } return(_sessionObjectCache); } default: { if (_defaultObjectCache == null) { _defaultObjectCache = new DefaultObjectCache(); } return(_defaultObjectCache); } } } }
public static TObject InitObject <TObject>(String cacheKey, CommonCacheStore store, TimeSpan timeout, Func <TObject> initializer) where TObject : class { var cache = GetCacheProvider(store); return(cache.InitObject(cacheKey, timeout, initializer)); }
public static void RemoveObject(String cacheKey, CommonCacheStore store) { var cache = GetCacheProvider(store); cache.RemoveObject(cacheKey); }
public static TObject InitObject <TObject>(String cacheKey, CommonCacheStore store, Func <TObject> initializer) where TObject : class { return(InitObject(cacheKey, store, TimeSpan.FromMinutes(15), initializer)); }
public static void SetObject <TObject>(String cacheKey, CommonCacheStore store, TimeSpan timeout, TObject @object) where TObject : class { InitObject(cacheKey, store, timeout, () => @object); }
public static void SetObject <TObject>(String cacheKey, CommonCacheStore store, TObject @object) where TObject : class { SetObject(cacheKey, store, TimeSpan.FromMinutes(15), @object); }
public static TObject GetObject <TObject>(String cacheKey, CommonCacheStore store) where TObject : class { var cache = GetCacheProvider(store); return(cache.GetObject <TObject>(cacheKey)); }
public static IEnumerable <KeyValuePair <String, Object> > GetObjects(CommonCacheStore store) { var cache = GetCacheProvider(store); return(cache.GetObjects()); }