Skip to content

Commit 4ebd4a0

Browse files
committed
Describe jitter setting
1 parent 0e0e805 commit 4ebd4a0

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

docs/getting_started/django_settings.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,27 @@ of those items may be deleted.
137137
If the delete process is too slow, then you can change this setting to use
138138
Django's ``QuerySet._raw_delete`` method. That runs significantly faster than
139139
``QuerySet.delete`` but it means that signals are not sent during that process.
140+
141+
142+
WAGTAIL_CACHE_TIMEOUT_JITTER_FUNC
143+
---------------------------------
144+
145+
.. versionadded::
146+
147+
An optional function that will be called to adjust the cache timeout each
148+
time a cache item is set. Set to None by default.
149+
150+
This can be used to add a random jitter to the cache timeout to avoid cache
151+
stampedes.
152+
153+
The function should take the timeout as an argument and return a new
154+
timeout. For example, to add a random jitter of up to 10% to the timeout:
155+
156+
.. code-block:: python
157+
158+
import random
159+
160+
def jitter_timeout(timeout):
161+
return timeout * random.uniform(0.9, 1.1)
162+
163+
WAGTAIL_CACHE_TIMEOUT_JITTER_FUNC = jitter_timeout

0 commit comments

Comments
 (0)