コード例 #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));
            }
        }
コード例 #2
0
        public string GetSidByUserId(string userId)
        {
            string userKey = $"{preUserKey}{userId}";

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

            return(null);
        }
コード例 #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);
        }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #6
0
        public bool SidExists(string sid)
        {
            string sidKey = $"{preSidKey}{sid}";

            return(RedisStoreHelper.KeyExists(sidKey));
        }