mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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:
1 parent
74398766a4
commit
7df32a86a3
1 file changed
+5
-1
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user