timkung
timkung

Reputation: 99

What are the correct steps to set up django-cache-machine?

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!

Upvotes: 1

Views: 5362

Answers (3)

Nishith Baravkar
Nishith Baravkar

Reputation: 21

Since major-version 1.0 > of django-cache-machine, some breaking changes have occured, LocMem, Memcached and PyLibMemcached, have been removed, so use

Backwards Incompatible Changes

Cache Machine previously included custom backends for LocMem, Memcached and PyLibMemcached. These were necessary because the core backends in old versions of Django did not support infinte timeouts. They now do, so Cache Machine’s custom backends are no longer necessary. They have been removed, so you should revert to using the core Django backends.

you can find them here now

django.core.cache.backends

Upvotes: 0

alireza jafari
alireza jafari

Reputation: 1

replace with this :

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

Upvotes: 0

drwrong
drwrong

Reputation: 11

Just install memcach with:

  pip install python-memcached

That solved the problem for me!

Upvotes: 1

Related Questions