fix(flash): record evict count on delete element

with: #1000150848

Signed-off-by: clinx <chenlin1@oppo.com>
(cherry picked from commit f10253c7a3)
This commit is contained in:
clinx 2025-08-21 17:45:37 +08:00 committed by chihe
parent 2ce4af6a64
commit 850bfb9305

View File

@ -244,7 +244,6 @@ func (c *fCache) CheckDiskSpace(dataPath string, key interface{}, size int64) (n
break
}
toEvicts[ent.Value.(*entry).key] = c.deleteElement(ent)
atomic.AddInt32(&c.evicts, 1)
n++
diskSpaceLeft += ent.Value.(*entry).value.(*CacheBlock).getAllocSize()
@ -296,7 +295,6 @@ func (c *fCache) Set(key, value interface{}, expiration time.Duration) (n int, e
c.DeleteKeyFromPreAllocatedKeyMap(ent.Value.(*entry).key)
}
toEvicts[ent.Value.(*entry).key] = c.deleteElement(ent)
atomic.AddInt32(&c.evicts, 1)
n++
}
}
@ -390,6 +388,7 @@ func (c *fCache) Evict(key interface{}) bool {
func (c *fCache) deleteElement(ent *list.Element) interface{} {
v := ent.Value.(*entry)
c.removeElement(ent)
atomic.AddInt32(&c.evicts, 1)
return v.value
}