1

I am new to Django and caching and is using Django 1.6.

I followed the instructions on django-cache-machine' page to install it.

1.pip install django-cache-machine

2.Add following to settings.py

CACHES = {
    'default': {
        'BACKEND': 'caching.backends.memcached.MemcachedCache',
        'LOCATION': 'localhost:11211',
        'PREFIX': 'wee:',
    },
}

3.Apply the changes on one of my models just as the minimal case in the instructions.

When I try to run server, it shows the following errors.

django.core.cache.backends.base.InvalidCacheBackendError: Could not find backend 'caching.backends.memcached.MemcachedCache': 'module' object has no attribute ' CacheClass'

I previously installed johnny-cache but quickly removed it and then installed cache machine. I dont know if it is relevent. Memcached is also running.

Thanks in advance!

EDIT:

Just found that it is already mentioned in one issue in the Github page of the app. https://github.com/jbalogh/django-cache-machine/issues/44

And a fix is pulled in. So I reinstall the github version.

pip install -e git://github.com/jbalogh/django-cache-machine.git#egg=django-cache-machine

Now it shows another error.

ImportError: No module named memcache

So I install another app called python-memcached. The server runs but no caching occurs.

I run python shell and the app works fine. So I think the problem is still django-cache-machine.

I guess django-cache-machine just not yet fully support Django 1.6.

If anyone knows how to get it work on Django 1.6+Python 2.7, please let me know.

Thanks again!

timkung
  • 99
  • 4
  • 10
  • 1
    Ref the docs: https://docs.djangoproject.com/en/dev/topics/cache/#memcached it looks like for BACKEND you should be using `'django.core.cache.backends.memcached.MemcachedCache'`. Seems consistent with the example here: https://github.com/jbalogh/django-cache-machine/blob/master/examples/cache_machine/settings.py – Tom Dalton Aug 08 '14 at 15:38
  • The example on github is using the backend I wrote above. Also, shouldn't I use the custom backend provided by django-cache-machine instead of the stock one from Django? – timkung Aug 08 '14 at 15:51
  • have you installed memcache server? – sharafjaffri May 15 '15 at 06:58

2 Answers2

1

Just install memcach with:

  pip install python-memcached

That solved the problem for me!

dwitvliet
  • 7,242
  • 7
  • 36
  • 62
drwrong
  • 11
  • 1
0

replace with this :

'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',