You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get a value from the cache or call ``func`` to set it and return it.
128
137
129
-
Retrieves a key value from the cache and sets the value if it does not exist.
138
+
This implementation is slightly more advanced that Django's. It provides thundering herd
139
+
protection, which prevents multiple threads/processes from calling the value-generating
140
+
function at the same time.
130
141
131
142
:param key: Location of the value
132
143
:param func: Callable used to set the value if key does not exist.
133
-
:param timeout:Number of seconds to hold value in cache.
144
+
:param timeout:Time in seconds that value at key is considered fresh.
134
145
:type timeout: Number of seconds or None
146
+
:param lock_timeout: Time in seconds that the lock will stay active and prevent other threads from acquiring the lock.
147
+
:type lock_timeout: Number of seconds or None
148
+
: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.
149
+
:type stale_cache_timeout: Number of seconds or None
135
150
136
151
137
152
.. function:: reinsert_keys(self):
@@ -147,12 +162,9 @@ Cache Methods Provided by django-redis-cache
Copy file name to clipboardExpand all lines: docs/intro_quick_start.rst
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Intro and Quick Start
4
4
Intro
5
5
=====
6
6
7
-
`django-redis-cache`_ is a cache backend for the `Django`_ webframework. It
7
+
`django-redis-cache`_ is a cache backend for the `Django`_ web framework. It
8
8
uses the `redis`_ server, which is a in-memory key-value data structure server.
9
9
Similar to the great `Memcached`_ in performance, it has several features that
10
10
makes it more appealing.
@@ -24,7 +24,7 @@ makes it more appealing.
24
24
* Many more.
25
25
26
26
Many of these features are irrelevant to caching, but can be used by other
27
-
areas of a web stack and therefore offer a compelling case to simplify your
27
+
areas of a web stack and therefore offers a compelling case to simplify your
28
28
infrastructure.
29
29
30
30
@@ -35,9 +35,9 @@ Quick Start
35
35
36
36
**Recommended:**
37
37
38
-
* `redis`_ >= 2.4
38
+
* `redis`_ >= 2.8
39
39
40
-
* `redis-py`_ >= 2.10.3
40
+
* `redis-py`_ >= 3.0.0
41
41
42
42
* `python`_ >= 2.7
43
43
@@ -58,6 +58,8 @@ of redis. Start the server by running ``./src/redis-server``
58
58
},
59
59
}
60
60
61
+
**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``.
0 commit comments