From b13c337d99eb7cb3a492807803c9efe33373c1ca Mon Sep 17 00:00:00 2001 From: icey-yu <119291641+icey-yu@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:10:08 +0800 Subject: [PATCH] fix: lru lock (#2613) * fix: lru lock * fix: lru lock * fix: lru lock --- pkg/localcache/lru/lru_lazy.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/localcache/lru/lru_lazy.go b/pkg/localcache/lru/lru_lazy.go index e7f7b8bd51..84aa980e8a 100644 --- a/pkg/localcache/lru/lru_lazy.go +++ b/pkg/localcache/lru/lru_lazy.go @@ -100,12 +100,12 @@ func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) setVs := make(map[K]*layLruItem[V]) for _, key := range keys { v, ok := x.core.Get(key) + x.lock.Unlock() if ok { - x.lock.Unlock() v.lock.Lock() expires, value, err1 := v.expires, v.value, v.err + v.lock.Unlock() if expires != 0 && expires > time.Now().UnixMilli() { - v.lock.Unlock() x.target.IncrGetHit() res[key] = value if err1 != nil { @@ -117,7 +117,6 @@ func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) } } queries = append(queries, key) - x.lock.Unlock() } values, err1 := fetch(queries) if err1 != nil {