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 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 #3
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 #4
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 #5
0
        /// <summary>
        /// 获取手机验证码
        /// </summary>
        public string GetPhoneVerificationCode(string key)
        {
            string newKey = $"{prePhoneVerificationCodeKey}_{key}";

            return(RedisStoreHelper.GetString(newKey));
        }