Open arielitovsky opened 9 months ago
this is shit,set twice and get nil
func TestTinyLFU(t *testing.T) { lfu := cache.NewTinyLFU(100, 300) lfu.Set("a", []byte("a")) lfu.Set("a", []byte("b")) lfu.Set("a", []byte("c")) value, ok := lfu.Get("a")
if !ok {
t.Errorf("expected=true got=false")
}
if string(value) != "c" {
t.Errorf("expected=c got=%s", value)
}
}
I expected that using TinyLFU would overwrite a value when setting it, just like Redis. However, overwriting a value doesn't seem to work. From what I can gather of the TinyLFU internals, it doesn't evict the old value.
Example test: