How to set item with no expiration?
ikrisliu opened this issue · 4 comments
ikrisliu commented
When I set the item's TTL field to 0, the cache.ttl()
function will reset TTL to default 1 hour.
croatiangrn commented
Set it to some negative number and that's it.
ikrisliu commented
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
}
Huskydog9988 commented
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.)