예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cr"></param>
        /// <param name="isUpdate"></param>
        /// <returns></returns>
        public static bool CreateOrUpdateTableInfo(UserCRoomInfo cr, bool isUpdate = false)
        {
            var tableid = cr.TableId;
            var tkey    = _TableInfo + tableid;
            //创建房间缓存最长65分钟
            var expire = 65 * 60;

            if (!isUpdate)
            {
                var putResult = redisClient.KeyObjSaveIfNotExists(tkey, cr, expire);
                if (!putResult)
                {
                    return(false);
                }
            }
            else
            {
                redisClient.KeyObjSaveAsync(tkey, cr, expire);
            }
            var strTableId = cr.TableId.ToString();

            if (cr.RoomOwner > 0)
            {
                redisClient.HashSetAsync(_UserCreateTable + cr.RoomOwner, strTableId, DateTime.Now.GetTimestamp(), expire);
            }
            if (cr.GroupId > 0)
            {
                redisClient.HashSetAsync(_GroupCreateTable + cr.GroupId, strTableId, DateTime.Now.GetTimestamp(), expire);
            }
            return(true);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cr"></param>
        /// <param name="oldOwnerId"></param>
        public static void SetTableOwnerInfo(UserCRoomInfo cr, uint oldOwnerId)
        {
            CreateOrUpdateTableInfo(cr, true);
            var strTableId = cr.TableId.ToString();

            if (oldOwnerId > 0)
            {
                redisClient.HashDelete(_UserCreateTable + oldOwnerId, strTableId);
            }
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cr"></param>
        public static void RemoveTableInfo(UserCRoomInfo cr)
        {
            if (cr == null)
            {
                return;
            }
            var tableid = cr.TableId;
            var tkey    = _TableInfo + tableid;

            redisClient.KeyDelete(tkey);
            var strTableId = cr.TableId.ToString();

            if (cr.RoomOwner > 0)
            {
                NoticeUserCTableOver(cr.TableId, cr.RoomOwner, cr.GroupId);
                redisClient.HashDeleteAsync(_UserCreateTable + cr.RoomOwner, strTableId);
            }
            if (cr.GroupId > 0)
            {
                redisClient.HashDeleteAsync(_GroupCreateTable + cr.GroupId, strTableId);
            }
        }