Closed snirye closed 10 months ago
There's ttlcache.NoTTL
for this. Though I agree, the Set()
docs could probably mention it as one of the options.
Thanks for the quick response.
You probably meant DefaultTTL.
But still, I think it not so natural to explicit mention this for using default behaviour, if it's possible to use same options mechanism that being used for the New
function
https://github.com/jellydator/ttlcache/blob/master/cache.go#L61
Like this:
Set(key K, value V, opts ...SetOption)
I would be happy to implement if it help
You probably meant DefaultTTL.
I meant NoTTL
, which is something you'd want to use if you don't want to set any TTL (that's what I gathered your intention was in the initial comment).
At the moment, there aren't any other SetOptions, so this change would be a bit premature. Besides, making a change like that would require us to release a new major version. And also, when this method was being designed, the goal was to have the TTL parameter as explicit as possible without having too much logic on top (e.g., having two methods: Set
and SetWithTTL
).
Set(key K, value V, opts ...[Option])
passing 0 as default is a bit confusing, and its also not documented