﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16006	Make cache lazy to allow test runners to switch cache backends	brianjaystanley	nobody	"django.core.cache.cache is currently a module-level variable that references an instance of the default cache backend from settings.CACHES. Loading the cache backend into a module-level variable makes it difficult to switch to a different cache backend at runtime. Switching cache backends at runtime would be useful in test runners, in order to be able to test caching-related functionality without populating a production cache. settings.CACHES supports multiple caches, but the only way to use a cache other than the ""default"" is by calling get_cache, but then only the caller has the reference to the new cache backend while other modules (including the cache-based session backends) will continue to use the default cache backend referenced by django.core.cache.cache.

The patch wraps the cache variable in SimpleLazyObject. This allows doing something like this in a test runner:

cache._wrapped = get_cache('test')

This doesn't break anything in the Django test suite.
"	Cleanup/optimization	closed	Core (Cache system)	1.3	Normal	wontfix		zimnyx@… brianjaystanley	Design decision needed	1	1	1	0	0	0
