forked from p53841790/wheat-cache
fix(lru): add key update length
This commit is contained in:
parent
19e1bb59a3
commit
7ac9651ef3
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue