infoscout / django-cache-utils

Django cache utilities
Other
26 stars 19 forks source link

Can't set non-expiring cache keys. #18

Open peymanmortazavi opened 5 years ago

peymanmortazavi commented 5 years ago

Because of the way this line is implemented (ignoring None and also 0 values) We can't use the following code:

cache.set('a', 'b', timeout=None)  # normally this should never expire.
cache.set('a', 'b', timeout=0)  # this should immediately get deleted. 

https://github.com/infoscout/django-cache-utils/blob/master/cache_utils/group_backend.py#L30

Django tries to keep this behavior consistent even when the provider doesn't support it by checking when the value is 0, never actually creating the entry.