Exemple #1
0
        protected override CacheEntry <T> PerformGet <T>(string key)
        {
            var memEntry = _useInMemoryCache ? _innerCacheProvider.Get <T>(key) : null;

            if (memEntry != null)
            {
                return(new CacheEntry <T>(key, memEntry));
            }

            var entry = GetCacheEntry(key);

            if (entry != null)
            {
                var cacheEntryAsString = entry.Get("CacheEntry");
                try
                {
                    // TODO: Disabled for beta due to a bug in ServiceStack deserializing CompositeEntitySchema: var cacheEntry = SerializationService.FromJson<CacheValueOf<T>>(cacheEntryAsString);
                    var cacheEntry = _fixedSerializer.FromJson <CacheValueOf <T> >(cacheEntryAsString);

                    var entryFromIndex = ReferenceEquals(cacheEntry, null)
                        ? null
                        : new CacheEntry <T>(key, cacheEntry);

                    if (entryFromIndex != null)
                    {
                        // Ensure we put it in our in-memory cache too
                        if (_useInMemoryCache)
                        {
                            _innerCacheProvider.AddOrChange(key, cacheEntry);
                        }
                        return(entryFromIndex);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Warn <CacheProvider>("Deserializing an entry from cache failed, {0}", ex.Message);
                }
            }

            return(null);
        }