コード例 #1
0
        public static void Set <T>(String name, String key, T data)
        {
            var redis = RedisFactory.GetService(name);

            if (redis != null)
            {
                redis.StringSet(key, JsonHelper.Serlaize <T>(data));
            }
        }
コード例 #2
0
        public static void Set <T>(String name, String key, T data, int cacheSeconds)
        {
            var redis = RedisFactory.GetService(name);

            if (redis != null)
            {
                redis.StringSet(key, JsonHelper.Serlaize <T>(data), new TimeSpan(0, 0, cacheSeconds));
            }
        }
コード例 #3
0
        public static void Delete(String name, String key)
        {
            var redis = RedisFactory.GetService(name);

            if (redis != null)
            {
                redis.KeyDelete(key);
            }
        }
コード例 #4
0
        public static T Get <T>(String name, String key)
        {
            T   data  = default(T);
            var redis = RedisFactory.GetService(name);

            if (redis != null)
            {
                String redisResult = redis.StringGet(key);
                if (String.IsNullOrEmpty(redisResult))
                {
                    data = JsonHelper.Deserialize <T>(redisResult);
                }
            }
            return(data);
        }