fix: lru lock

This commit is contained in:
icey-yu 2024-09-12 15:36:01 +08:00
parent de20311c4b
commit 34ced79c1b

View File

@ -102,7 +102,9 @@ func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error))
v, ok := x.core.Get(key)
x.lock.Unlock()
if ok {
v.lock.Lock()
expires, value, err1 := v.expires, v.value, v.err
v.lock.Unlock()
if expires != 0 && expires > time.Now().UnixMilli() {
x.target.IncrGetHit()
res[key] = value