Commit 04448249 authored by Sean Bleier's avatar Sean Bleier

Update docs for new features.

parent 94eab537
......@@ -93,6 +93,13 @@ Standard Django Cache API
:param version: Version of key
:type version: Integer or None
.. function:: touch(self, key, timeout):
Updates the timeout on a key.
:param key: Location of the value
:rtype: bool
Cache Methods Provided by django-redis-cache
......@@ -124,14 +131,22 @@ Cache Methods Provided by django-redis-cache
:param version: Version of the keys
.. function:: get_or_set(self, key, func[, timeout=None]):
.. function:: get_or_set(self, key, func[, timeout=None, lock_timeout=None, stale_cache_timeout=None]):
Get a value from the cache or call ``func`` to set it and return it.
Retrieves a key value from the cache and sets the value if it does not exist.
This implementation is slightly more advanced that Django's. It provides thundering herd
protection, which prevents multiple threads/processes from calling the value-generating
function too much.
:param key: Location of the value
:param func: Callable used to set the value if key does not exist.
:param timeout: Number of seconds to hold value in cache.
:param timeout: Time in seconds that value at key is considered fresh.
:type timeout: Number of seconds or None
:param lock_timeout: Time in seconds that the lock will stay active and prevent other threads from acquiring the lock.
:type lock_timeout: Number of seconds or None
:param stale_cache_timeout: Time in seconds that the stale cache will remain after the key has expired. If ``None`` is specified, the stale value will remain indefinitely.
:type stale_cache_timeout: Number of seconds or None
.. function:: reinsert_keys(self):
......@@ -147,12 +162,9 @@ Cache Methods Provided by django-redis-cache
:param key: Location of the value
:rtype: bool
.. function:: lock(self, key, timeout=None, sleep=0.1, blocking_timeout=None, thread_local=True)
.. function:: expire(self, key, timeout):
Set the expire time on a key
:param key: Location of the value
:rtype: bool
See docs for `redis-py`_.
.. _redis-py: https://redis-py.readthedocs.io/en/latest/_modules/redis/client.html#Redis.lock
......@@ -4,7 +4,7 @@ Intro and Quick Start
Intro
=====
`django-redis-cache`_ is a cache backend for the `Django`_ webframework. It
`django-redis-cache`_ is a cache backend for the `Django`_ web framework. It
uses the `redis`_ server, which is a in-memory key-value data structure server.
Similar to the great `Memcached`_ in performance, it has several features that
makes it more appealing.
......@@ -24,7 +24,7 @@ makes it more appealing.
* Many more.
Many of these features are irrelevant to caching, but can be used by other
areas of a web stack and therefore offer a compelling case to simplify your
areas of a web stack and therefore offers a compelling case to simplify your
infrastructure.
......@@ -35,7 +35,7 @@ Quick Start
**Recommended:**
* `redis`_ >= 2.4
* `redis`_ >= 2.8
* `redis-py`_ >= 2.10.3
......@@ -59,7 +59,7 @@ of redis. Start the server by running ``./src/redis-server``
}
**Warning: By default, django-redis-cache set keys in the database 1 of Redis. By default, a session with redis-cli start on database 0. Switch to database 1 with** ``SELECT 1``.
.. _Django: https://www.djangoproject.com/
.. _django-redis-cache: http://github.com/sebleier/django-redis-cache
.. _redis-py: http://github.com/andymccurdy/redis-py/
......
......@@ -414,7 +414,7 @@ class BaseRedisCache(BaseCache):
timeout=DEFAULT_TIMEOUT,
lock_timeout=None,
stale_cache_timeout=None):
"""Get a value from the cache or call `func` to set it and return it.
"""Get a value from the cache or call ``func`` to set it and return it.
This implementation is slightly more advanced that Django's. It provides thundering herd
protection, which prevents multiple threads/processes from calling the value-generating
......@@ -422,11 +422,11 @@ class BaseRedisCache(BaseCache):
There are three timeouts you can specify:
`timeout`: Time in seconds that value at `key` is considered fresh.
`lock_timeout`: Time in seconds that the lock will stay active and prevent other threads or
``timeout``: Time in seconds that value at ``key`` is considered fresh.
``lock_timeout``: Time in seconds that the lock will stay active and prevent other threads or
processes from acquiring the lock.
`stale_cache_timeout`: Time in seconds that the stale cache will remain after the key has
expired. If `None` is specified, the stale value will remain indefinitely.
``stale_cache_timeout``: Time in seconds that the stale cache will remain after the key has
expired. If ``None`` is specified, the stale value will remain indefinitely.
"""
if not callable(func):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment