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 <noreply@anthropic.com>
This commit is contained in:
loks0nandClaude Fable 5 committed 2026-08-25 18:08:19 +01:00
1 parent 74398766a4
commit 7df32a86a3
1 file changed
+5 -1
+5 -1
View File
@@ -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]);
}