Ejemplo n.º 1
0
        /// <summary>
        /// redis测试
        /// </summary>
        private static void TestRedis()
        {
            var redisClient = new RedisWrapper();
            var result      = string.Empty;

            //get
            var name = redisClient.Get("name");

            if (name.IsNullOrEmpty())
            {
                redisClient.GetOrAdd("name", () => { return("kobe"); });
            }

            //add
            redisClient.Add("id", "100");
            result = redisClient.Get("id");

            //update
            redisClient.Update("id", "101", 3 * 60);
            result = redisClient.Get("id");

            //remove
            redisClient.Remove("id");
            result = redisClient.Get("id");
        }
Ejemplo n.º 2
0
        public async Task <List <MAS_AddressTypeDto> > GetMASAddressType(CancellationToken ct = default(CancellationToken))
        {
            try
            {
                var fieldListTemp = new List <MAS_AddressTypeDto>();
                if (!RedisWrapper.Get(sessionAddressType, Zero, Zero, Zero, out fieldListTemp))
                {
                    fieldListTemp = await DotnetCoreSvr.GetMASAddressType(ct);

                    RedisWrapper.Add(fieldListTemp, sessionAddressType, Zero, Zero, Zero);
                }
                return(fieldListTemp);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }