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 3
3
import time
4
4
from collections import OrderedDict
5
5
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
+
6
12
from django .conf import settings
7
13
from 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
+ )
9
20
from django .core .cache .backends .base import BaseCache
10
21
from django .dispatch import Signal
11
22
from django .middleware import cache as middleware_cache
@@ -246,8 +257,14 @@ def enable_instrumentation(self):
246
257
else :
247
258
cache .caches = CacheHandlerPatch ()
248
259
260
+ try :
261
+ cache .cache = ConnectionProxy (cache .caches , DEFAULT_CACHE_ALIAS )
262
+ except NameError :
263
+ pass
264
+
249
265
def disable_instrumentation (self ):
250
266
cache .caches = original_caches
267
+ cache .cache = original_cache
251
268
# While it can be restored to the original, any views that were
252
269
# wrapped with the cache_page decorator will continue to use a
253
270
# monkey patched cache.
You can’t perform that action at this time.
0 commit comments