From b89f5ddb4e985f8e761802a049fb3c5c909f7865 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Thu, 21 Oct 2021 11:51:20 -0700 Subject: [PATCH] Add a note about working around the locmem cache restriction (#448) Per a conversation on twitter with @jezdez about this, here's a stab at some docs. I've tried to strike a balance: I want to tell people about this option, but not directly provide the code to avoid copy-paste without thinking. --- docs/backends.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/backends.rst b/docs/backends.rst index 8b95315..4e330d0 100644 --- a/docs/backends.rst +++ b/docs/backends.rst @@ -137,6 +137,19 @@ configured cache backend to enable this feature, e.g. "default":: incompatible with cross-process caching like the local memory cache backend included in Django because correct cache invalidation can't be guaranteed. + + If you try this, Constance will throw an error and refuse + to let your application start. You can work around this by + subclassing ``constance.backends.database.DatabaseBackend`` + and and overriding `__init__` to remove the check. You'll + want to consult the source code for that function to see + exactly how. + + We're deliberately being vague about this, because it's + dangerous; the behavior is undefined, and could even cause + your app to crash. Nevertheless, there are some limited + circumstances in which this could be useful, but please + think carefully before going down this path. .. note:: By default Constance will autofill the cache on startup and after saving any of the config values. If you want to disable the cache