CELERY_CACHE_BACKEND setting docs improvements
The docs on the CELERY_CACHE_BACKEND could be improved.
For one thing, they claim that celery can be used with pylibmc, and that in fact python-memcached will only be used if pylibmc is not installed. However, this doesn't seem to be true. If I don't have python-memcached installed, the setup described in the docs will cause the celeryd management command to fail.
Additionally, the docs make no mention of the fact that (at least in django 1.3) one has the option of using the CACHES setting to define multiple cache backends. Because CELERY_CACHE_BACKED is passed directly into django.core.cache.get_cache, one can simply set CELERY_CACHE_BACKEND to the key for the appropriate cache, instead of trying to figure out celery-specific settings. This would be much simpler, especially since the arguments accepted by get_cache are only described in its docstring, not in the django cache documentation.
I wasn't aware of the multiple cache backends. Would you be willing to write this part?
Wait, the CELERY_CACHE_BACKEND part is for the Celery cache backend, django-celery uses the Django celery backend, so indeed pylibmc won't work there. For some reason it seems that CELERY_CACHE_BACKEND can also be used to specify a custom backend for Celery in Django. Confusing!
I'm a little unclear on the distinction you're making. The cache backend in djcelery.backends.cache directly uses whatever caches are available in django by calling django.core.cache.get_cache. It doesn't care whether the cache is pylibmc or not. Or does celery use the cache backend for something else as well?
Also, according to the docs, pylibmc is explicitly supported, and is preferred to python-memcached, which doesn't seem to actually be the case and which was my original reason for posting.
I agree with melinath - was just very surprised to have to install python-memcache to have django-celery work when I have both celery and django on pylibmc!!!
For those who find this issue, the sollution is simple. (putting it here as it shows up high on google, so I'm sure others will find this as well)
If you put an URI in your CELERY_CACHE_BACKEND, Django (Celery forwards the url to django when using django-celery) will attempt to load the module.. seeing the memcached backend has several variations (pylibmc, python-memcached), it somehow defaults to python-memcached.
However, you can also put the name of the entry in the CACHES setting, django will attempt to load that and use that as the settings to create the cache class.
So, in short:
CELERY_CACHE_BACKEND = "default"
in your celery config
and
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
}
}
in your django config. Ofcourse you can use different keys to separate celery's cache backend from django's cache backend.