예제 #1
0
        public LotteryData Insert(LotteryData newData)
        {
            var redisKey = AppUtils.GetLotteryRedisKey(newData.LotteryType, LsConstant.LotteryDataCacheKey);

            try
            {
                CacheHelper.AddCacheListItem(redisKey, newData);
                if (CacheHelper.GetCache <IList <LotteryData> >(redisKey).Count >= LsConstant.LOAD_HISTORY_LOTTERYDATA)
                {
                    //var mostOldLottery = RedisHelper.GetAll<LotteryData>(redisKey).Last();
                    //RedisHelper.RemoveList(redisKey, mostOldLottery);
                }
            }
            catch (Exception ex)
            {
                LogDbHelper.LogError(ex, GetType() + "UpdateLotteryDataCache");
                throw ex;
            }

            var lotteryDataId = _lotteryDapperService.Add(newData);

            return(CacheHelper.GetCache <IList <LotteryData> >(redisKey).First(p => p.Id == newData.Id));
        }