2

I want to use multiple caching engines in one django project. In example I use sorl.thumbnail, that generated many sql queries to get/set thumbnail for model image. For caching this queries I use memcached backend. But, other caches stopped working, I mean template caching with {% cache ... %}, and also via API cache.get(), cache.set(). I want to be something like this

CACHES = {
'default': {
    'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    'LOCATION': '127.0.0.1:11211',
    },
'filebased': {
    'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',

    }

}

How can I use 'filebased' cache in template? Because {% cache %} uses memcached backend, and it produces many queries, especially using trees (django-mptt)

Igor
  • 479
  • 5
  • 13

1 Answers1

4

Via the API you can do this :

from django.core import cache
filebased_cache = cache.get_cache('filebased')
filebased_cache.set('blah', 1)

I'm afraid the template cache doesn't provide a way to use another than the default. You probably have to write your own if you want to do this.

Dominique PERETTI
  • 1,063
  • 12
  • 12