﻿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
7398	Making it easier to add custom cache backends	lau@…	nobody	"I ran into an inconvenience with the Django cache. I wanted to add my own custom cache backend without having to muck about with the Django core. This proved to be a bit challenging since the backend importer uses a complete path to the module (e.g. ""django.core.cache.backends.memcached""). 

I did a small patch which lets you define extra backend modules without touching the Django folder. Essentially it uses the BACKENDS dictionary in core/cache/__init__.py to keep information about the full import paths, like this:

{{{ 
BACKENDS = {
    # name for use in settings file --> path to the backend module
    'memcached': 'django.core.cache.backends.memcached',
    'locmem': 'django.core.cache.backends.locmem',
    'file': 'django.core.cache.backends.filebased',
    'db': 'django.core.cache.backends.db',
    'dummy': 'django.core.cache.backends.dummy',
}

if hasattr(settings, ""CACHE_BACKEND_MODULES""):
    BACKENDS.update(settings.CACHE_BACKEND_MODULES)
}}}

So if I wanted to add a new backend in my project, I'd do something like:

settings.py:
{{{
CACHE_BACKEND_MODULES = {
    'penandpaper': 'backends.cache.penandpaper'
}
}}}

and place the backend in my_app/backends/cache/.

There has been a bit of talk about it lately on the developer mailing list:

http://groups.google.com/group/django-developers/browse_thread/thread/e0fbaff909c44336"		closed	Core (Cache system)	dev		fixed		lau@…	Accepted	1	0	0	0	0	0
