diff options
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/codeberg.org/gruf/go-cache/v3/result/cache.go | 18 | ||||
-rw-r--r-- | vendor/modules.txt | 2 |
2 files changed, 14 insertions, 6 deletions
diff --git a/vendor/codeberg.org/gruf/go-cache/v3/result/cache.go b/vendor/codeberg.org/gruf/go-cache/v3/result/cache.go index 74644b073..a86a72c77 100644 --- a/vendor/codeberg.org/gruf/go-cache/v3/result/cache.go +++ b/vendor/codeberg.org/gruf/go-cache/v3/result/cache.go @@ -228,11 +228,15 @@ func (c *Cache[Value]) Load(lookup string, load func() (Value, error), keyParts var evict func() - // Acquire cache lock. + // Lock cache. c.cache.Lock() + defer func() { + // Unlock cache. c.cache.Unlock() + if evict != nil { + // Call evict. evict() } }() @@ -266,21 +270,25 @@ func (c *Cache[Value]) Store(value Value, store func() error) error { var evict func() - // Acquire cache lock. + // Lock cache. c.cache.Lock() + defer func() { + // Unlock cache. c.cache.Unlock() + if evict != nil { + // Call evict. evict() } + + // Call invalidate. + c.invalid(value) }() // Store result in cache. evict = c.store(result) - // Call invalidate. - c.invalid(value) - return nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 0dc2cd772..88789b334 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -13,7 +13,7 @@ codeberg.org/gruf/go-bytesize # codeberg.org/gruf/go-byteutil v1.1.2 ## explicit; go 1.16 codeberg.org/gruf/go-byteutil -# codeberg.org/gruf/go-cache/v3 v3.4.1 +# codeberg.org/gruf/go-cache/v3 v3.4.3 ## explicit; go 1.19 codeberg.org/gruf/go-cache/v3 codeberg.org/gruf/go-cache/v3/result |