Fix cache mem size not including key size
parent
ae821f4e2d
commit
a5afaf7499
|
@ -359,6 +359,7 @@ func (c *Cache) WriteMulti(values map[string][]Value) error {
|
|||
c.decreaseSize(uint64(Values(v).Size()))
|
||||
}
|
||||
if newKey {
|
||||
addedSize += uint64(len(k))
|
||||
c.increaseSize(uint64(len(k)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -444,6 +444,10 @@ func TestCache_Snapshot_Stats(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if got, exp := c.stats.MemSizeBytes, int64(16)+3; got != exp {
|
||||
t.Fatalf("got %v, expected %v", got, exp)
|
||||
}
|
||||
|
||||
_, err := c.Snapshot()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -458,6 +462,10 @@ func TestCache_Snapshot_Stats(t *testing.T) {
|
|||
if got, exp := c.stats.CachedBytes, int64(16)+3; got != exp {
|
||||
t.Fatalf("got %v, expected %v", got, exp)
|
||||
}
|
||||
|
||||
if got, exp := c.stats.MemSizeBytes, int64(16)+3; got != exp {
|
||||
t.Fatalf("got %v, expected %v", got, exp)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCache_CacheEmptySnapshot(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue