mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 08:13:09 -06:00
Keep the remaining 10% of cached entries
This commit is contained in:
parent
2b4162523f
commit
1a1d7b8076
|
|
@ -93,7 +93,12 @@ func cacheCleaner(caches ...*InMemoryLRUCachePartition) {
|
||||||
for {
|
for {
|
||||||
time.Sleep(time.Minute)
|
time.Sleep(time.Minute)
|
||||||
for _, cache := range caches {
|
for _, cache := range caches {
|
||||||
cache.lru.RemoveOldest()
|
// Hold onto the last 10% of the cache entries, since
|
||||||
|
// otherwise a quiet period might cause us to evict all
|
||||||
|
// cache entries entirely.
|
||||||
|
if cache.lru.Len() > cache.maxEntries/10 {
|
||||||
|
cache.lru.RemoveOldest()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue