fix(lru): add key update length

This commit is contained in:
bandl 2021-11-29 16:11:28 +08:00
parent 19e1bb59a3
commit 7ac9651ef3
1 changed files with 3 additions and 0 deletions

View File

@ -123,6 +123,9 @@ func (lru *SingleCache) Add(key *proto.BaseKey, val structure.KeyBaseInterface)
}
if elVal, ok := lru.lruMap[key.Key]; ok {
lru.li.MoveToFront(elVal)
oldSize := elVal.Value.(structure.KeyBaseInterface).SizeByte()
lru.UpdateLruSize(structure.UpdateLength(val.SizeByte() - oldSize))
elVal.Value = keyBaseVal
return nil
}