Skip to content

Commit

Permalink
fix: lru lock
Browse files Browse the repository at this point in the history
  • Loading branch information
icey-yu committed Sep 12, 2024
1 parent 80c71b7 commit 3a45679
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/localcache/lru/lru_lazy.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,12 @@ func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error))
queries := make([]K, 0)
setVs := make(map[K]*layLruItem[V])
for _, key := range keys {
x.lock.Unlock()
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
if expires != 0 && expires > time.Now().UnixMilli() {
v.lock.Unlock()
x.target.IncrGetHit()
res[key] = value
if err1 != nil {
Expand All @@ -117,7 +116,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 {
Expand Down

0 comments on commit 3a45679

Please sign in to comment.