From 0b7ee7aa993f70866fea2703fcc04eaf53584419 Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Thu, 5 Sep 2024 18:15:18 -0700 Subject: [PATCH] fix order --- cache/cache.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cache/cache.go b/cache/cache.go index d2a6205..57e87f9 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -59,8 +59,8 @@ func (c *Cache[Key, Value]) Put(key Key, val Value) bool { // If there is an existing item for this key, remove it. if old, ok := c.store.Check(key); ok { - c.size -= c.sizeOf(old) c.store.Remove(key) + c.size -= c.sizeOf(old) c.onEvict(key, old) c.count-- } @@ -187,7 +187,7 @@ type Store[Key comparable, Value any] interface { // This counts as an access of the value. // // If key is already present, Store should panic. - // This should not be possible. + // That condition should not be possible. Store(key Key, val Value) // Remove removes the specified key from the cache. If key is not present, @@ -199,7 +199,7 @@ type Store[Key comparable, Value any] interface { // for each item evicted, if any. // // If Evict cannot satisfy the specified size, it should panic. - // This should not be possible. + // That condition should not be possible. Evict(need int64, sizeOf func(Value) int64, onEvict func(Key, Value)) int64 }