public UserInfoEntity GetUserInfoByUid(long uid) { UserInfoEntity userInfo = null; string cacheKey = RedisKeyConst.UserInfoKeyByUIdCacheKey(uid); string userInfoKey = redisClient.Get(cacheKey); if (!string.IsNullOrEmpty(userInfoKey)) { userInfo = redisClient.Get <UserInfoEntity>(userInfoKey); } if (userInfo != null) { return(userInfo); } userInfo = userInfoDao.GetUserInfoByUid(uid); if (userInfo != null) { if (string.IsNullOrEmpty(userInfoKey)) { userInfoKey = RedisKeyConst.UserInfoByOpenIdAndUIdCacheKey(userInfo.OpenId, userInfo.UId); redisClient.Set(cacheKey, userInfoKey, RedisKeyConst.UserInfoCacheSecond); } //缓存一个月 redisClient.Set(userInfoKey, userInfo, RedisKeyConst.UserInfoCacheSecond); } return(userInfo); }