Closed R4wm closed 4 months ago
I think it's not possible. As a workaround, you could get the item and reset it with the modified ttl value.
var ttl time.Duration = cache.DefaultTTL
if previousItem := cache.Get(key); previousItem != nil {
ttl = previousItem.ExpiresAt().Sub(time.Now())
}
cache.Set(key, value, ttl)
At present not updating an existing expiration time isn't possible, though it might a good feature for one of the future versions. We could add a new ttlcache.PreviousTTL
option that would indicate that the previous TTL should be set after an update.
Implemented in #121
Its not clear to me how to ".Set()" and not start the expire time over again. Can someone point to reference or doc or advise ?