fix: Upgrade status-go to the most recent version of release branch which contains memory fix
Fix #4990
This commit is contained in:
committed by
Michał Iskierko
parent
03d490156a
commit
66cf3d21b9
11
vendor/github.com/jellydator/ttlcache/v3/cache.go
generated
vendored
11
vendor/github.com/jellydator/ttlcache/v3/cache.go
generated
vendored
@@ -148,6 +148,10 @@ func (c *Cache[K, V]) set(key K, value V, ttl time.Duration) *Item[K, V] {
|
||||
c.evict(EvictionReasonCapacityReached, c.items.lru.Back())
|
||||
}
|
||||
|
||||
if ttl == PreviousOrDefaultTTL {
|
||||
ttl = c.options.ttl
|
||||
}
|
||||
|
||||
// create a new item
|
||||
item := newItem(key, value, ttl, c.options.enableVersionTracking)
|
||||
elem = c.items.lru.PushFront(item)
|
||||
@@ -478,6 +482,13 @@ func (c *Cache[K, V]) Items() map[K]*Item[K, V] {
|
||||
// Range stops the iteration.
|
||||
func (c *Cache[K, V]) Range(fn func(item *Item[K, V]) bool) {
|
||||
c.items.mu.RLock()
|
||||
|
||||
// Check if cache is empty
|
||||
if c.items.lru.Len() == 0 {
|
||||
c.items.mu.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
for item := c.items.lru.Front(); item != c.items.lru.Back().Next(); item = item.Next() {
|
||||
i := item.Value.(*Item[K, V])
|
||||
c.items.mu.RUnlock()
|
||||
|
||||
20
vendor/github.com/jellydator/ttlcache/v3/item.go
generated
vendored
20
vendor/github.com/jellydator/ttlcache/v3/item.go
generated
vendored
@@ -9,6 +9,10 @@ const (
|
||||
// NoTTL indicates that an item should never expire.
|
||||
NoTTL time.Duration = -1
|
||||
|
||||
// PreviousOrDefaultTTL indicates that existing TTL of item should be used
|
||||
// default TTL will be used as fallback if item doesn't exist
|
||||
PreviousOrDefaultTTL time.Duration = -2
|
||||
|
||||
// DefaultTTL indicates that the default TTL value of the cache
|
||||
// instance should be used.
|
||||
DefaultTTL time.Duration = 0
|
||||
@@ -58,17 +62,23 @@ func (item *Item[K, V]) update(value V, ttl time.Duration) {
|
||||
defer item.mu.Unlock()
|
||||
|
||||
item.value = value
|
||||
|
||||
// update version if enabled
|
||||
if item.version > -1 {
|
||||
item.version++
|
||||
}
|
||||
|
||||
// no need to update ttl or expiry in this case
|
||||
if ttl == PreviousOrDefaultTTL {
|
||||
return
|
||||
}
|
||||
|
||||
item.ttl = ttl
|
||||
|
||||
// reset expiration timestamp because the new TTL may be
|
||||
// 0 or below
|
||||
item.expiresAt = time.Time{}
|
||||
item.touchUnsafe()
|
||||
|
||||
// update version if enabled
|
||||
if item.version > -1 {
|
||||
item.version++
|
||||
}
|
||||
}
|
||||
|
||||
// touch updates the item's expiration timestamp.
|
||||
|
||||
Reference in New Issue
Block a user