From 8ff8861603717ff53a5063fb359337f8d508c59a Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Wed, 10 Jan 2024 16:13:55 +0800 Subject: [PATCH] local cache --- pkg/common/localcache/cache.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/common/localcache/cache.go b/pkg/common/localcache/cache.go index dedcf6aa9..228538fa6 100644 --- a/pkg/common/localcache/cache.go +++ b/pkg/common/localcache/cache.go @@ -34,7 +34,9 @@ type cache[V any] struct { func (c *cache[V]) onEvict(key string, value V) { lks := c.link.Del(key) for k := range lks { - c.local.Del(k) + if key != k { // prevent deadlock + c.local.Del(k) + } } } @@ -42,13 +44,10 @@ func (c *cache[V]) del(key ...string) { for _, k := range key { lks := c.link.Del(k) c.local.Del(k) - //fmt.Println(">>>", lks) for k := range lks { c.local.Del(k) - //fmt.Println("+++", k) } } - //fmt.Println() } func (c *cache[V]) Get(ctx context.Context, key string, fetch func(ctx context.Context) (V, error), opts ...*opt.Option) (V, error) {