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,9 +93,14 @@ func cacheCleaner(caches ...*InMemoryLRUCachePartition) {
|
|||
for {
|
||||
time.Sleep(time.Minute)
|
||||
for _, cache := range caches {
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type InMemoryLRUCachePartition struct {
|
||||
|
|
|
|||
Loading…
Reference in a new issue