Open ikrisliu opened 2 years ago
Set it to some negative number and that's it.
I tried, but it's not working. Because it will be reset to 0 by the below codes.
func (item *Item) ttl() time.Duration {
const defaultTTL = time.Hour
if item.TTL < 0 {
return 0
}
if item.TTL != 0 {
if item.TTL < time.Second {
log.Printf("too short TTL for key=%q: %s", item.Key, item.TTL)
return defaultTTL
}
return item.TTL
}
return defaultTTL
}
Negative TTL behavior differs from what you'd expect: https://github.com/go-redis/cache/pull/84
Based on my very short peruse of the codebase, I think only the check needs to be removed. (Assuming whatever issues #84 alludes too no longer exists.)
When I set the item's TTL field to 0, the
cache.ttl()
function will reset TTL to default 1 hour.