mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-07 06:03:09 -06:00
Don't enforce mutability checks for now
This commit is contained in:
parent
2488058e62
commit
e1f4a485f5
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue