This commit is contained in:
Neil Alexander 2022-06-14 10:02:50 +01:00
parent 4613203763
commit f948dc8c18
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -132,10 +132,8 @@ func NewRistrettoCachePartition(name string, mutable bool, maxEntries int, maxAg
func (c *RistrettoCachePartition) Set(key string, value interface{}) {
if !c.mutable {
if peek, ok := c.ristretto.Get(key); ok {
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))
}
if entry, ok := c.ristretto.Get(key); ok && entry != value {
panic(fmt.Sprintf("invalid use of immutable cache tries to mutate existing value of %q", key))
}
}
c.ristretto.SetWithTTL(key, value, 1, c.maxAge)