Skip to content

Commit 0d30713

Browse files
committed
pref: avoid CacheUnmarshalView in locks
Signed-off-by: Rueian <[email protected]>
1 parent a7301ca commit 0d30713

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cache.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,16 @@ func (f *flatten) Flight(key, cmd string, ttl time.Duration, now time.Time) (Red
338338
return RedisMessage{}, af
339339
}
340340
f.mu.Lock()
341-
defer f.mu.Unlock()
342341
e = f.cache[key]
343342
v, expired := e.find(cmd, ts)
344343
if v != nil {
345344
f.llTail(e)
345+
f.mu.Unlock()
346346
var ret RedisMessage
347347
_ = ret.CacheUnmarshalView(v)
348348
return ret, nil
349349
}
350+
defer f.mu.Unlock()
350351
if expired {
351352
f.remove(e)
352353
}

0 commit comments

Comments
 (0)