Example #1
0
        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);
                }
                }
            }
        }
Example #2
0
        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));
        }
Example #3
0
        public static void RemoveObject(String cacheKey, CommonCacheStore store)
        {
            var cache = GetCacheProvider(store);

            cache.RemoveObject(cacheKey);
        }
Example #4
0
 public static TObject InitObject <TObject>(String cacheKey, CommonCacheStore store, Func <TObject> initializer) where TObject : class
 {
     return(InitObject(cacheKey, store, TimeSpan.FromMinutes(15), initializer));
 }
Example #5
0
 public static void SetObject <TObject>(String cacheKey, CommonCacheStore store, TimeSpan timeout, TObject @object) where TObject : class
 {
     InitObject(cacheKey, store, timeout, () => @object);
 }
Example #6
0
 public static void SetObject <TObject>(String cacheKey, CommonCacheStore store, TObject @object) where TObject : class
 {
     SetObject(cacheKey, store, TimeSpan.FromMinutes(15), @object);
 }
Example #7
0
        public static TObject GetObject <TObject>(String cacheKey, CommonCacheStore store) where TObject : class
        {
            var cache = GetCacheProvider(store);

            return(cache.GetObject <TObject>(cacheKey));
        }
Example #8
0
        public static IEnumerable <KeyValuePair <String, Object> > GetObjects(CommonCacheStore store)
        {
            var cache = GetCacheProvider(store);

            return(cache.GetObjects());
        }