diff options
author | 2023-07-24 10:20:11 +0000 | |
---|---|---|
committer | 2023-07-24 10:20:11 +0000 | |
commit | c9f3539b5a9f9746f1629b51a64fb9adf8398cad (patch) | |
tree | f2b25a9248f92af5a41f208d0920463a0b307361 /vendor/codeberg.org/gruf/go-cache | |
parent | [chore]: Bump github.com/jackc/pgconn from 1.14.0 to 1.14.1 (#2024) (diff) | |
download | gotosocial-c9f3539b5a9f9746f1629b51a64fb9adf8398cad.tar.xz |
[chore]: Bump codeberg.org/gruf/go-cache/v3 from 3.4.1 to 3.4.3 (#2022)
Diffstat (limited to 'vendor/codeberg.org/gruf/go-cache')
-rw-r--r-- | vendor/codeberg.org/gruf/go-cache/v3/result/cache.go | 18 |
1 files changed, 13 insertions, 5 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 } |