Created
February 13, 2019 16:04
-
-
Save kaedroho/cefd778ff5ea85166ded1ef817c62c6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
from django.core.cache import caches | |
from django.core.cache.backends.dummy import DummyCache | |
class AlwaysDummyCache: | |
def __getitem__(self, key): | |
return DummyCache(None) | |
@contextmanager | |
def disable_caches(): | |
caches = caches._caches.caches | |
caches._caches.caches = AlwaysDummyCache() | |
try: | |
yield | |
finally: | |
caches._caches.caches = caches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment