Skip to content

Commit 2db704a

Browse files
committed
feat: correct the way of handling expired cache
Signed-off-by: Rueian <[email protected]>
1 parent b91898b commit 2db704a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cache.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,13 @@ func (f *flatten) Update(key, cmd string, val RedisMessage) (sxat int64) {
377377
f.remove(e)
378378
ep = e.next
379379
}
380-
if e := f.cache[key]; e == nil {
380+
e := f.cache[key]
381+
if e != nil && e.cmd == cmd {
382+
f.size -= e.size
383+
f.llDel(e)
384+
e = nil
385+
}
386+
if e == nil {
381387
fe.key = key
382388
f.cache[key] = fe
383389
f.llAdd(fe)

0 commit comments

Comments
 (0)