lib/workingsetcache: check more frequently for cache size overflow

This should reduce the probability of cache size limit overflow
This commit is contained in:
Aliaksandr Valialkin 2022-04-05 18:04:03 +03:00
parent 4785d04312
commit 29cebb3d95
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1

View File

@ -149,8 +149,6 @@ func (c *Cache) expirationWatcher(expireDuration time.Duration) {
prev := c.prev.Load().(*fastcache.Cache)
prev.Reset()
curr := c.curr.Load().(*fastcache.Cache)
var cs fastcache.Stats
curr.UpdateStats(&cs)
c.prev.Store(curr)
// Use c.maxBytes/2 instead of cs.MaxBytesSize for creating new cache,
// since cs.MaxBytesSize may not match c.maxBytes/2, so the created cache
@ -162,7 +160,7 @@ func (c *Cache) expirationWatcher(expireDuration time.Duration) {
}
func (c *Cache) cacheSizeWatcher() {
t := time.NewTicker(time.Minute)
t := time.NewTicker(1500 * time.Millisecond)
defer t.Stop()
var maxBytesSize uint64