diff options
author | 2023-04-19 13:46:42 +0200 | |
---|---|---|
committer | 2023-04-19 13:46:42 +0200 | |
commit | a3d2774db5e5be5b99d652a88d1a13223d3d834d (patch) | |
tree | cd5622dca8b38fc54dc72dfb1793353300486098 /vendor/codeberg.org/gruf/go-cache/v3/result/cache.go | |
parent | [chore]: Bump mvdan.cc/xurls/v2 from 2.4.0 to 2.5.0 (#1702) (diff) | |
download | gotosocial-a3d2774db5e5be5b99d652a88d1a13223d3d834d.tar.xz |
[chore]: Bump codeberg.org/gruf/go-cache/v3 from 3.2.3 to 3.2.5 (#1701)
Bumps codeberg.org/gruf/go-cache/v3 from 3.2.3 to 3.2.5.
---
updated-dependencies:
- dependency-name: codeberg.org/gruf/go-cache/v3
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-cache/v3/result/cache.go')
-rw-r--r-- | vendor/codeberg.org/gruf/go-cache/v3/result/cache.go | 7 |
1 files changed, 6 insertions, 1 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 91ca2255e..3dbb017e9 100644 --- a/vendor/codeberg.org/gruf/go-cache/v3/result/cache.go +++ b/vendor/codeberg.org/gruf/go-cache/v3/result/cache.go @@ -28,6 +28,7 @@ type Lookup struct { // cache would be in wrapping a database, allowing caching of sql.ErrNoRows. type Cache[Value any] struct { cache ttl.Cache[int64, result[Value]] // underlying result cache + invalid func(Value) // store unwrapped invalidate callback. lookups structKeys // pre-determined struct lookups ignore func(error) bool // determines cacheable errors copy func(Value) Value // copies a Value type @@ -114,7 +115,8 @@ func (c *Cache[Value]) SetInvalidateCallback(hook func(Value)) { if hook == nil { // Ensure non-nil hook. hook = func(Value) {} - } + } // store hook. + c.invalid = hook c.cache.SetInvalidateCallback(func(item *ttl.Entry[int64, result[Value]]) { for _, key := range item.Value.Keys { // Delete key->pkey lookup @@ -241,6 +243,9 @@ func (c *Cache[Value]) Store(value Value, store func() error) error { // Cache result c.store(result) + // Call invalidate. + c.invalid(value) + return nil } |