forked from SteamWar/SteamWar
Revert "Add EventCache for efficient retrieval of event groups and teams"
This reverts commit8b4f864f99. Revert "Refactor EventFights and Fight classes to improve player initialization and retrieval" This reverts commit8d705e7a84. Revert "Refactor EventFights and Fight classes to improve player initialization and retrieval" This reverts commit78352a3e67.
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.data
|
||||
|
||||
import de.steamwar.routes.ResponseGroups
|
||||
import de.steamwar.routes.ResponseTeam
|
||||
import de.steamwar.sql.EventGroup
|
||||
import de.steamwar.sql.Team
|
||||
|
||||
class EventCache {
|
||||
private val groupCache = mutableMapOf<Int, ResponseGroups>()
|
||||
private val teamCache = mutableMapOf<Int, ResponseTeam>()
|
||||
|
||||
fun getGroup(id: Int): ResponseGroups = groupCache.getOrPut(id) { ResponseGroups(EventGroup.byId(id).get()) }
|
||||
fun getTeam(id: Int): ResponseTeam = teamCache.getOrPut(id) { ResponseTeam(Team.byId(id)) }
|
||||
|
||||
fun convertGroup(group: EventGroup) = ResponseGroups(group).also { groupCache[group.getId()] = it }
|
||||
fun convertTeam(team: Team) = ResponseTeam(team).also { teamCache[team.teamId] = it }
|
||||
}
|
||||
Reference in New Issue
Block a user