Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyring in database #66

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4c3e515
Move keyring into database
aweakley Jan 25, 2024
44510fd
Better method name
aweakley Jan 25, 2024
05b2c41
Prevent Memcached warning
aweakley Feb 12, 2024
a171092
Ensure active_for_url_regexes has more than one to work with
aweakley Feb 12, 2024
9cbf223
Better style
aweakley Feb 12, 2024
c1178f5
Correct typing syntax
aweakley Feb 13, 2024
1a5a2d6
Additional typing syntax fix
aweakley Feb 13, 2024
9bd919c
Use latest black version
aweakley Feb 13, 2024
1460249
Improve test coverage
aweakley Feb 13, 2024
5d6080c
Optionally use _raw_delete for db KeyringItems for speed on large caches
aweakley Feb 13, 2024
b99a7b9
Correct typing syntax
aweakley Feb 13, 2024
ace1379
Additional typing syntax fix
aweakley Feb 13, 2024
73140ed
Update docs to include additional setting
aweakley Feb 13, 2024
3d6d7f8
Increase URL field length
aweakley Mar 24, 2024
caec651
Ruff formatting after rebase
aweakley Jul 29, 2024
1254d88
Fix reversion from rebase
aweakley Jul 29, 2024
dfb02fe
Requested changes for PR #66
aweakley Jul 29, 2024
436a877
Mypy ignore rule
aweakley Jul 30, 2024
ead0a37
Support _raw_delete when clearing the whole cache
aweakley Aug 21, 2024
0d2b14f
Add clear_expired_cache_items cmd
jacobcolyvan Aug 22, 2024
1f8d937
Documentation for clear expired setting
aweakley Sep 30, 2024
0c77dfd
Add optional jitter to cache timeouts
aweakley Aug 23, 2024
cfaf159
Ensure KeyringItem is validated
aweakley Sep 30, 2024
da573a3
Add comment
aweakley Sep 30, 2024
58f3f74
Describe jitter setting
aweakley Oct 23, 2024
2386b30
URLs with GET parameters can be very long
aweakley Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions docs/getting_started/django_settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,64 @@ own unique page in the cache, set this value to ``None`` or ``[]``.
If you feel as though the spammers have won, and want the nuclear option, you
can set this to ``[r".*"]`` which will ignore all querystrings. This is surely
a terrible idea, but it can be done.


.. _WAGTAIL_CACHE_CLEAR_EXPIRED_ON_SET:

WAGTAIL_CACHE_CLEAR_EXPIRED_ON_SET
----------------------------------

.. versionadded::

This setting will clear any expired `KeyringItems` as a new item is set,
and is OFF by default.

If set to `True`, as a cache item is set the manager will delete any expired
items from the database. If there are likely to be many expired items in the
cache, then that might be time-consuming so this setting can be turned off.
You can use the Django management command `wagtail_cache_clear_expired_items`
periodically to clear expired items instead.


.. _WAGTAIL_CACHE_USE_RAW_DELETE:

WAGTAIL_CACHE_USE_RAW_DELETE
----------------------------

.. versionadded:: 2.3.0

This setting will use Django's ``QuerySet._raw_delete`` method to clear
KeyringItems from the database. This is fast but means that signals are not
sent during that process. This is OFF by default.

If your cache is large, then there can be many ``KeyringItem`` objects in the
database. When you publish a Wagtail page that is high in the tree, many
of those items may be deleted.

If the delete process is too slow, then you can change this setting to use
Django's ``QuerySet._raw_delete`` method. That runs significantly faster than
``QuerySet.delete`` but it means that signals are not sent during that process.


WAGTAIL_CACHE_TIMEOUT_JITTER_FUNC
---------------------------------

.. versionadded::

An optional function that will be called to adjust the cache timeout each
time a cache item is set. Set to None by default.

This can be used to add a random jitter to the cache timeout to avoid cache
stampedes.

The function should take the timeout as an argument and return a new
timeout. For example, to add a random jitter of up to 10% to the timeout:

.. code-block:: python

import random

def jitter_timeout(timeout):
return timeout * random.uniform(0.9, 1.1)

WAGTAIL_CACHE_TIMEOUT_JITTER_FUNC = jitter_timeout
Loading
Loading