예제 #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);
        }