mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-07 06:03:09 -06:00
Tweak
This commit is contained in:
parent
4613203763
commit
f948dc8c18
|
|
@ -132,10 +132,8 @@ func NewRistrettoCachePartition(name string, mutable bool, maxEntries int, maxAg
|
||||||
|
|
||||||
func (c *RistrettoCachePartition) Set(key string, value interface{}) {
|
func (c *RistrettoCachePartition) Set(key string, value interface{}) {
|
||||||
if !c.mutable {
|
if !c.mutable {
|
||||||
if peek, ok := c.ristretto.Get(key); ok {
|
if entry, ok := c.ristretto.Get(key); ok && entry != value {
|
||||||
if entry, ok := peek.(*inMemoryLRUCacheEntry); ok && entry.value != value {
|
panic(fmt.Sprintf("invalid use of immutable cache tries to mutate existing value of %q", key))
|
||||||
panic(fmt.Sprintf("invalid use of immutable cache tries to mutate existing value of %q", key))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.ristretto.SetWithTTL(key, value, 1, c.maxAge)
|
c.ristretto.SetWithTTL(key, value, 1, c.maxAge)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue