public static List <GoodsModel> GetListAll(int playerId, int belongsTo, out bool fromCache) { fromCache = false; string redisKey = RedisKeyHelper.GetRedisKeyName(RedisKeyConfig.Goods, playerId.ToString(), belongsTo.ToString()); var list = redisCacheHelper.StringGet <List <GoodsModel> >(redisKey); if (list != null) { fromCache = true; return(list); } else { list = GoodsDAL.GetListAll(playerId, belongsTo); redisCacheHelper.StringSet(redisKey, list, CommonConfig.DefRedisExpiry); return(list); } }
public static PlayerbasisModel GetSingleOrDefault(int playerId, out bool fromCache) { fromCache = false; string redisKey = RedisKeyHelper.GetRedisKeyName(RedisKeyConfig.Playerbasis, playerId.ToString()); var cacheModel = redisCacheHelper.StringGet <PlayerbasisModel>(redisKey); if (cacheModel != null) { fromCache = true; return(cacheModel); } else { var model = new PlayerbasisModel(); model = GetSingleOrDefault(model, new KeyValue <int> { Key = nameof(model.PlayerId), Value = playerId }); redisCacheHelper.StringSet(redisKey, model, CommonConfig.DefRedisExpiry); return(model); } }
public string Get(string key) { return(_helper.StringGet <string>(key)); }