diff options
| author | zedr <rigel.discala@propylon.com> | 2014-02-23 22:58:26 +0000 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2014-03-04 21:16:35 +0100 |
| commit | 6fe22b30e007b7ac49eae48a53e7ba0a4ee79a4b (patch) | |
| tree | 38fe1af6a021e4b8a50cc88d2d1975a36ff7042a /django/core/cache/backends/base.py | |
| parent | 24f0113fb9bc1a47094a12eff2ae78e8f2bcb0fb (diff) | |
Fixed #22085 -- Added a feature for setting non-expiring keys as the default.
This feature allows the default `TIMEOUT` Cache argument to be set to `None`,
so that cache instances can set a non-expiring key as the default,
instead of using the default value of 5 minutes.
Previously, this was possible only by passing `None` as an argument to
the set() method of objects of type `BaseCache` (and subtypes).
Diffstat (limited to 'django/core/cache/backends/base.py')
| -rw-r--r-- | django/core/cache/backends/base.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py index ae83865db8..4b7806fc29 100644 --- a/django/core/cache/backends/base.py +++ b/django/core/cache/backends/base.py @@ -52,10 +52,11 @@ def get_key_func(key_func): class BaseCache(object): def __init__(self, params): timeout = params.get('timeout', params.get('TIMEOUT', 300)) - try: - timeout = int(timeout) - except (ValueError, TypeError): - timeout = 300 + if timeout is not None: + try: + timeout = int(timeout) + except (ValueError, TypeError): + timeout = 300 self.default_timeout = timeout options = params.get('OPTIONS', {}) |
