Disable Cachalot in runtime
You can still change the state of CACHALOT_ENABLED, but it’s not recommended because it’s not 100% safe either: during the time we update the settings, there’s around 1 ms during which concurrent writes fail to invalidate the cache. That method of changing the state of CACHALOT_ENABLED dynamically is visible in CachalotPanel, use:
from cachalot.settings import cachalot_settings
from django.conf import settings
settings.CACHALOT_ENABLED = False
cachalot_settings.reload()
I chose to keep it in CachalotPanel because it is made to be used only in development environments, typically with just one process, no concurrency all that on a disposable non-master database.
Thank you for the solution you provide in #88, it’s very cool of you to share it, it can even be used as a workaround if others don’t agree with me. However, I’ll not merge it because, in addition to the concerns above, it feels over-engineered for such a simple feature. It doesn’t add much compare to my not-recommended-workaround above, from what I understand. Yes, it adds a context manager, but it could be easily added to the workaround above with something like:
from contextlib import contextmanager
from cachalot.settings import cachalot_settings
from django.conf import settings
@contextmanager
def cachalot_disabled():
settings.CACHALOT_ENABLED = False
cachalot_settings.reload()
try:
yield
finally:
settings.CACHALOT_ENABLED = True
cachalot_settings.reload()
with cachalot_disabled():
.....