Perf: cache zero building levels in getFieldLevelInVillage [#155] (#235)

This commit is contained in:
Ferywir
2026-06-16 17:22:10 +02:00
committed by GitHub
parent b7feb7f2a1
commit 0b1bd44d22
+6 -3
View File
@@ -3729,9 +3729,12 @@ class MYSQLi_DB implements IDbConnection {
$vid = (int) $vid; $vid = (int) $vid;
// first of all, check if we should be using cache and whether the field // first of all, check if we should be using cache and whether the field
// required is already cached // required is already cached. NB: use isset() rather than the generic
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$fieldLevelsInVillageSearchCache, $vid.$fieldType)) && !is_null($cachedValue)) { // returnCachedContent(), which treats a cached level of 0 as "empty" and
return $cachedValue; // re-queries it on every call — buildings the village does not own
// (level 0, very common) would otherwise never be cached.
if ($use_cache && isset(self::$fieldLevelsInVillageSearchCache[$vid.$fieldType])) {
return self::$fieldLevelsInVillageSearchCache[$vid.$fieldType];
} }
// $fieldType can be both, integer and string, to be used in the IN statement, // $fieldType can be both, integer and string, to be used in the IN statement,