From 7df32a86a3801655b1620ce85bfc1d489f9c6bc7 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 25 Aug 2026 18:08:19 +0100 Subject: [PATCH] fix(geo): evict a slice instead of flushing the whole cache A full table no longer wipes every hot record to insert one; evicting ~10% bounds churn when concurrent workers hit the full table together. Co-Authored-By: Claude Fable 5 --- src/Appwrite/Locale/Geo.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Locale/Geo.php b/src/Appwrite/Locale/Geo.php index 2de177f35f..fbc6b391a0 100644 --- a/src/Appwrite/Locale/Geo.php +++ b/src/Appwrite/Locale/Geo.php @@ -106,9 +106,13 @@ class Geo } if (!$this->cache->set($ip, ['value' => $value])) { - // Table full — flush so the cache keeps tracking current traffic. + // Table full — evict a slice so most hot records survive. + $evict = (int) (self::CACHE_SIZE / 10); foreach ($this->cache as $key => $row) { $this->cache->del($key); + if (--$evict <= 0) { + break; + } } $this->cache->set($ip, ['value' => $value]); }