Opened 11 years ago
Closed 11 years ago
#22085 closed New feature (fixed)
Allow CACHES['cache']['TIMEOUT']: None to set a non-expiring timeout by default.
Reported by: | honi | Owned by: | Rigel Di Scala |
---|---|---|---|
Component: | Core (Cache system) | Version: | 1.6 |
Severity: | Normal | Keywords: | cache timeout |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
BaseCache will try to cast the default timeout to int, which will throw a TypeError if timeout is None, thus setting default_timeout to 300.
Relevant lines here: https://github.com/django/django/blob/master/django/core/cache/backends/base.py#L54-L59
Django 1.6 made some changes to allow setting the cache timeout to None for non expiring keys, as described here: https://github.com/django/django/blob/master/django/core/cache/backends/base.py#L54-L59
Explicitly passing None in cache.set works as expected. It does not work if set in CACHE dict in django settings.
This currently does not work for me (keys expire in 300 seconds):
CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'unique-snowflake', 'TIMEOUT': None } }
Change History (6)
comment:1 by , 11 years ago
Easy pickings: | unset |
---|---|
Summary: | TIMEOUT==None defined in CACHE settings is discarded by BaseCache init code → Allow CACHES['cache']['TIMEOUT']: None to set a non-expiring timeout by default. |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → New feature |
comment:2 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 11 years ago
I have implemented this feature and written several tests for it.
The pull request is here: https://github.com/django/django/pull/2365
comment:4 by , 11 years ago
Has patch: | set |
---|
comment:5 by , 11 years ago
Needs documentation: | set |
---|
The patch needs to include an update to the documentation and a mention in the release notes.
comment:6 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This is outside of the scope of the changes in Django 1.6 so it's really more of a feature request than a bug.