Don't enforce mutability checks for now

This commit is contained in:
Neil Alexander 2022-06-14 14:18:37 +01:00
parent 2488058e62
commit e1f4a485f5
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -1,7 +1,6 @@
package caching
import (
"fmt"
"time"
"github.com/dgraph-io/ristretto"
@ -77,6 +76,7 @@ type RistrettoCachePartition[K keyable, V any] struct {
}
func (c *RistrettoCachePartition[K, V]) Set(key K, value V) {
/*
if !c.Mutable {
if v, ok := c.cache.Get(key); ok {
if fmt.Sprintf("%v", v) != fmt.Sprintf("%v", value) { // TODO: this is yucky
@ -84,6 +84,7 @@ func (c *RistrettoCachePartition[K, V]) Set(key K, value V) {
}
}
}
*/
cost := int64(1)
if cv, ok := any(value).(costable); ok {
cost = int64(cv.CacheCost())
@ -95,9 +96,11 @@ func (c *RistrettoCachePartition[K, V]) Unset(key K) {
if c.cache == nil {
return
}
/*
if !c.Mutable {
panic(fmt.Sprintf("invalid use of immutable cache tries to unset value of %v", key))
}
*/
c.cache.Del(key)
}