1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
        private bool GetCacheCoupon(string udid, int campId, out Coupon coupon)
        {
            using (var conn = RedisBase.GetConnection(waitForOpen: true))
            {
                Task<long> taskListLen = conn.Lists.GetLength(1, "camp:" + campId);
                taskListLen.Wait();

                if (taskListLen.Result == 0)
                {
                    coupon = null;
                    return false;
                }

                var dataTask = conn.Lists.RemoveFirstString(1, "camp:" + campId);
                dataTask.Wait();
            
                var dataCoupon = JsonConvert.DeserializeObject<CouponModule.Common.Model.Coupon>(dataTask.Result);
                coupon = Mapper.Map<Coupon>(dataCoupon);
                
                return true;
            }
        }