go-redis / cache

Cache library with Redis backend for Golang
https://redis.uptrace.dev/guide/go-redis-cache.html
BSD 2-Clause "Simplified" License
757 stars 95 forks source link

why not support ttl = -1 #65

Closed mozhemeng closed 3 years ago

mozhemeng commented 3 years ago

I found I can set ttl = -1 in go-redis, but in cache when ttl < 0 it will be set to 0 by following code in Item.ttl():

if item.TTL < 0 {
    return 0
}

and because of this can't set some special cache permanently

vmihailenco commented 3 years ago

This library assumes that you always want some expiration time for cached items. I think it is a fine assumption in most cases and we should not change it.

I encourage everyone to fork this library to make changes they need. That is what I do regularly as well.

OneSeven commented 3 years ago

This library assumes that you always want some expiration time for cached items. I think it is a fine assumption in most cases and we should not change it.

I encourage everyone to fork this library to make changes they need. That is what I do regularly as well.

Interfering with the user's decision is not a good library behavior, please remove this artificial restriction!