コード例 #1
0
        public T Get <T>(string key)
        {
            var model = default(T);

            try
            {
                var runtimeCacheObject = CurrentRuntimeCache.Get <T>(key);
                if (runtimeCacheObject != null)
                {
                    return(runtimeCacheObject);
                }

                model = Db.StringGet(key).ToString().FromJson <T>();
            }
            catch (RedisConnectionException ex)
            {
                return(CacheManager.UseBackupConnection(ex).Get <T>(key));
            }
            catch
            {
                // ignored
            }

            return(model);
        }
コード例 #2
0
        public object Get(string key)
        {
            try
            {
                var runtimeCacheObject = CurrentRuntimeCache.Get(key);
                return(runtimeCacheObject ?? Db.StringGet(key).ToString().FromJson <object>());
            }
            catch (RedisConnectionException ex)
            {
                return(CacheManager.UseBackupConnection(ex).Get(key));
            }
            catch
            {
                // ignored
            }

            return(null);
        }