Synchronize team cache access to ensure thread safety

Signed-off-by: Chaoscaot <max@maxsp.de>
This commit is contained in:
2025-12-17 21:28:36 +01:00
parent 19c6ad0965
commit 1eea792e23
+2 -2
View File
@@ -41,10 +41,10 @@ class Team(id: EntityID<Int>) : IntEntity(id) {
private val teamCache = mutableMapOf<Int, Team>()
@JvmStatic
fun clear() = teamCache.clear()
fun clear() = synchronized(teamCache) { teamCache.clear() }
@JvmStatic
fun byId(id: Int) = teamCache.computeIfAbsent(id) { useDb { Team[id] } }
fun byId(id: Int) = synchronized(teamCache) { teamCache.computeIfAbsent(id) { useDb { Team[id] } } }
@JvmStatic
fun get(name: String) = useDb { find { (TeamTable.name.lowerCase() eq name.lowercase() or (TeamTable.kuerzel.lowerCase() eq name.lowercase())) and not(TeamTable.deleted) }.firstOrNull() }