コード例 #1
0
        public void GetRedisValue()
        {
            //初始化redis连接信息
            Nodis.RedisPoolBuilder.Init("192.168.4.79:2181", "codis-mango");
            //获取redis连接数据库
            string value = "null";

            using (var redisClient = RedisPoolBuilder.GetClient())
            {
                redisClient.Db = 5;
                redisClient.Set <string>("codisproxytest", "zhh");
                value = redisClient.Get <string>("codisproxytest");
                redisClient.Remove("codisproxytest");
            }
            Assert.AreEqual("zhh", value);
        }
コード例 #2
0
        // GET api/values
        public string Get()
        {
            string result = "null";

            try
            {
                using (var redisClient = RedisPoolBuilder.GetClient())
                {
                    redisClient.Db = 5;
                    var value = redisClient.Get <string>("codis-proxy");
                    result = value;
                    log.DebugFormat("get:{0}:{1},{2}={3}", redisClient.Host, redisClient.Port, "codis-proxy", value);
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("异常信息:{0}", ex.Message.ToString());
            }
            return(result);
        }