Exemple #1
0
        public void UpdateExpire(string sid)
        {
            string sidKey = $"{preSidKey}{sid}";

            if (RedisStoreHelper.KeyExists(sidKey))
            {
                string userKey = RedisStoreHelper.GetString(sidKey);
                RedisStoreHelper.KeyExpire(userKey, TimeSpan.FromMinutes(keyExpire));
                RedisStoreHelper.KeyExpire(sidKey, TimeSpan.FromMinutes(keyExpire));
            }
        }
Exemple #2
0
        public string GetSidByUserId(string userId)
        {
            string userKey = $"{preUserKey}{userId}";

            if (RedisStoreHelper.KeyExists(userKey))
            {
                return(RedisStoreHelper.HashGetString(userKey, "Sid"));
            }

            return(null);
        }
Exemple #3
0
        public async Task <UserInfo> GetUserInfoFromCached(string sid)
        {
            string sidKey = $"{preSidKey}{sid}";

            if (RedisStoreHelper.KeyExists(sidKey))
            {
                string userKey = RedisStoreHelper.GetString(sidKey);
                return(await RedisStoreHelper.HashGetValueAsync <UserInfo>(userKey, "UserInfo"));
            }

            return(null);
        }
Exemple #4
0
        public void RemoveUserCached(string sid)
        {
            string sidKey = $"{preSidKey}{sid}";

            if (RedisStoreHelper.KeyExists(sidKey))
            {
                string userKey = RedisStoreHelper.GetString(sidKey);
                RedisStoreHelper.KeyDelete(userKey);

                RedisStoreHelper.KeyDelete(sidKey);
            }
        }
Exemple #5
0
        public List <UserRoleRelation> GetUserRoleBySid(string sid)
        {
            string sidKey = $"{preSidKey}{sid}";

            if (RedisStoreHelper.KeyExists(sidKey))
            {
                string userKey = RedisStoreHelper.GetString(sidKey);
                return(RedisStoreHelper.HashGetValue <List <UserRoleRelation> >(userKey, "UserRole"));
            }

            return(null);
        }
Exemple #6
0
        public void SetUserCached(string sid, UserInfo userInfo, List <UserRoleRelation> userRole)
        {
            string sidKey  = $"{preSidKey}{sid}";
            string userKey = $"{preUserKey}{userInfo.Id}";

            RedisStoreHelper.HashSetString(userKey, "Sid", sid);
            RedisStoreHelper.HashSetValue <UserInfo>(userKey, "UserInfo", userInfo);
            RedisStoreHelper.HashSetValue <List <UserRoleRelation> >(userKey, "UserRole", userRole);
            RedisStoreHelper.KeyExpire(userKey, TimeSpan.FromMinutes(keyExpire));

            RedisStoreHelper.SetString(sidKey, userKey, TimeSpan.FromMinutes(keyExpire));
        }
Exemple #7
0
        /// <summary>
        /// 获取手机验证码
        /// </summary>
        public string GetPhoneVerificationCode(string key)
        {
            string newKey = $"{prePhoneVerificationCodeKey}_{key}";

            return(RedisStoreHelper.GetString(newKey));
        }
Exemple #8
0
        /// <summary>
        /// 存储手机验证码
        /// </summary>
        public void SetPhoneVerificationCode(string key, string value)
        {
            string newKey = $"{prePhoneVerificationCodeKey}_{key}";

            RedisStoreHelper.SetString(newKey, value, TimeSpan.FromMinutes(1));
        }
Exemple #9
0
        /// <summary>
        /// 移除图片验证码
        /// </summary>
        public void RemoveImageVerificationCode(string key)
        {
            string newKey = $"{preImgVerificationCodeKey}_{key}";

            RedisStoreHelper.KeyDelete(newKey);
        }
Exemple #10
0
        public bool SidExists(string sid)
        {
            string sidKey = $"{preSidKey}{sid}";

            return(RedisStoreHelper.KeyExists(sidKey));
        }