1
0
mirror of https://github.com/django/django.git synced 2024-12-27 19:46:22 +00:00

[1.8.x] Clarified timeout=0 in cache docs.

Backport of e519ee1d35 from master
This commit is contained in:
Thomas Güttler 2015-02-11 16:00:12 +01:00 committed by Tim Graham
parent 8d1816db87
commit 6b8c8d7e18

View File

@ -366,14 +366,14 @@ Each cache backend can be given additional arguments to control caching
behavior. These arguments are provided as additional keys in the behavior. These arguments are provided as additional keys in the
:setting:`CACHES` setting. Valid arguments are as follows: :setting:`CACHES` setting. Valid arguments are as follows:
* :setting:`TIMEOUT <CACHES-TIMEOUT>`: The default timeout, in * :setting:`TIMEOUT <CACHES-TIMEOUT>`: The default timeout, in
seconds, to use for the cache. This argument defaults to ``300`` seconds (5 minutes). seconds, to use for the cache. This argument defaults to ``300`` seconds (5 minutes).
.. versionadded:: 1.7 .. versionadded:: 1.7
You can set ``TIMEOUT`` to ``None`` so that, by default, cache keys never You can set ``TIMEOUT`` to ``None`` so that, by default, cache keys never
expire. expire. A value of ``0`` causes keys to immediately expire (effectively
"don't cache").
* :setting:`OPTIONS <CACHES-OPTIONS>`: Any options that should be * :setting:`OPTIONS <CACHES-OPTIONS>`: Any options that should be
passed to the cache backend. The list of valid options will vary passed to the cache backend. The list of valid options will vary
@ -774,7 +774,8 @@ The basic interface is ``set(key, value, timeout)`` and ``get(key)``::
The ``timeout`` argument is optional and defaults to the ``timeout`` argument The ``timeout`` argument is optional and defaults to the ``timeout`` argument
of the appropriate backend in the :setting:`CACHES` setting (explained above). of the appropriate backend in the :setting:`CACHES` setting (explained above).
It's the number of seconds the value should be stored in the cache. Passing in It's the number of seconds the value should be stored in the cache. Passing in
``None`` for ``timeout`` will cache the value forever. ``None`` for ``timeout`` will cache the value forever. A ``timeout`` of ``0``
won't cache the value.
If the object doesn't exist in the cache, ``cache.get()`` returns ``None``:: If the object doesn't exist in the cache, ``cache.get()`` returns ``None``::