File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 33import time
44from collections import OrderedDict
55
6+ try :
7+ from django .utils .connection import ConnectionProxy
8+ except ImportError :
9+ # Django 3.1 and below doesn't have a ConnectionProxy
10+ pass
11+
612from django .conf import settings
713from django .core import cache
8- from django .core .cache import CacheHandler , caches as original_caches
14+ from django .core .cache import (
15+ DEFAULT_CACHE_ALIAS ,
16+ CacheHandler ,
17+ cache as original_cache ,
18+ caches as original_caches ,
19+ )
920from django .core .cache .backends .base import BaseCache
1021from django .dispatch import Signal
1122from django .middleware import cache as middleware_cache
@@ -246,8 +257,14 @@ def enable_instrumentation(self):
246257 else :
247258 cache .caches = CacheHandlerPatch ()
248259
260+ try :
261+ cache .cache = ConnectionProxy (cache .caches , DEFAULT_CACHE_ALIAS )
262+ except NameError :
263+ pass
264+
249265 def disable_instrumentation (self ):
250266 cache .caches = original_caches
267+ cache .cache = original_cache
251268 # While it can be restored to the original, any views that were
252269 # wrapped with the cache_page decorator will continue to use a
253270 # monkey patched cache.
You can’t perform that action at this time.
0 commit comments