fix: 玩家出牌/过牌时刷新UserRoomKey TTL

This commit is contained in:
wtz
2026-02-22 23:11:14 +08:00
parent 79fee6bc06
commit 72918c3b8d

View File

@@ -646,6 +646,10 @@ func (gm *GameManager) PlayCards(roomID, playerID string, cards []models.Card) e
} }
gm.saveRoom(ctx, room) gm.saveRoom(ctx, room)
// 刷新用户-房间关联的TTL
if player.UserID != "" {
gm.rdb.Set(ctx, redis.UserRoomKey(player.UserID), roomID, redis.RoomTTL)
}
return nil return nil
} }
@@ -686,6 +690,13 @@ func (gm *GameManager) Pass(roomID, playerID string) error {
} }
gm.saveRoom(ctx, room) gm.saveRoom(ctx, room)
// 刷新用户-房间关联的TTL
for _, p := range room.Players {
if p.ID == playerID && p.UserID != "" {
gm.rdb.Set(ctx, redis.UserRoomKey(p.UserID), roomID, redis.RoomTTL)
break
}
}
return nil return nil
} }