1

I'm missing something with memcached

  • System = redhat
  • yum install memcached
  • pip install python-memcached

I added this to the bottom of my setting.py

CACHES = {
  'default': {
    'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    'LOCATION': '/export/harris112/memcached.sock',
    'TIMEOUT': 18000,
    'KEY_PREFIX': 'askbot',
  }
}
CACHE_TIMEOUT = 18000
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True

and I attempt to run locally for testing

(python-two-seven)[root@kitt uvcdatASKBOT]# /etc/init.d/memcached start
Starting memcached: 
(python-two-seven)[root@kitt uvcdatASKBOT]# python manage.py runserver `hostname -i`:8000
Validating models...



************************
*                      *
*   Askbot self-test   *
*                      *
************************

Please attend to the following:

Cache server is unavailable.
Check your CACHE... settings and make sure that the cache backend is working properly.

If necessary, type ^C (Ctrl-C) to stop the program
(to disable the self-test add ASKBOT_SELF_TEST = False).

turns out I've missed something… Any suggestions?

mattbenh's avatar
15
mattbenh
asked 2013-12-09 16:54:02 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

1

Your memcached.sock file is very likely not in that location. You can see where it is with this command:

netstat -an | grep memcached.sock

If you don't see any results then your memcached server is either not running, or its listening on a TCP port. Check if it's listening on TCP with:

netstat -an | grep 11211

If you see a result there then you'll need to change your settings to:

CACHES = {
  'default': {
    'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    'LOCATION': '127.0.0.1:11211',
    'TIMEOUT': 18000,
    'KEY_PREFIX': 'askbot',
  }
}
CACHE_TIMEOUT = 18000
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
JStarcher's avatar
71
JStarcher
answered 2013-12-09 20:31:06 -0500
edit flag offensive 0 remove flag delete link

Comments

Thank you! it was running under TCP, and with that change it starts and has no cache warnings / errors.

mattbenh's avatar mattbenh (2013-12-10 10:37:21 -0500) edit
add a comment see more comments
1

It could be that /export/harris112/memcached.sock is not accessible or is not there or the memcached not configured to use that system socket, the default I think is using a TCP port.

Evgeny's avatar
13.2k
Evgeny
answered 2013-12-09 17:06:43 -0500
edit flag offensive 0 remove flag delete link

Comments

I'm no TCP expert so is this useful information (python-three-three)[root@kitt aims-site]# ps -e | grep memcached 29483 ? 00:00:00 memcached

mattbenh's avatar mattbenh (2013-12-09 18:04:58 -0500) edit

This tells us that memcached is running, 29483 is the process ID which isn't useful in this case. Check my post below and accept the answer if it is helpful. Cheers

JStarcher's avatar JStarcher (2013-12-10 00:05:11 -0500) edit
add a comment see more comments