Exemplo n.º 1
0
 public virtual ICacheItem <T> GetItem <T>(string key)
 {
     try
     {
         return(IsDisabled ? null : _cache.Get <T>(key));
     }
     catch (Exception e)
     {
         throw new CacheServiceException(string.Format("Error searching item key {0} in cache {1}", key, CacheId), e);
     }
 }
Exemplo n.º 2
0
        bool ICacheable.GetFromCache(ICacheEngine cacheEngine, CacheKey cacheKey, out object item)
        {
            T    cachedItem;
            bool found = cacheEngine.Get(cacheKey, out cachedItem);

            item = cachedItem;
            return(found);
        }
Exemplo n.º 3
0
        public bool Get <T>(CacheKey cacheKey, out T cacheItem)
        {
            if (_memoryCacheEngine.Get(cacheKey, out cacheItem))
            {
                return(true);
            }

            if (_redisCacheEngine.Get(cacheKey, out cacheItem))
            {
                //if the item is in the redis cache but not the memory cache, add it to the memory level
                _memoryCacheEngine.Put(new CacheItemInfo
                {
                    Item = cacheItem,
                    Key  = cacheKey
                });

                return(true);
            }

            return(false);
        }