Ask Your Question
1

I'm missing something with memcached

asked 2013-12-09 16:54:02 -0600

mattbenh gravatar image
  • 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?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2013-12-09 20:31:06 -0600

JStarcher gravatar image

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
edit flag offensive delete link more

Comments

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

mattbenh gravatar imagemattbenh ( 2013-12-10 10:37:21 -0600 )edit
1

answered 2013-12-09 17:06:43 -0600

Evgeny gravatar image

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.

edit flag offensive delete link more

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 gravatar imagemattbenh ( 2013-12-09 18:04:58 -0600 )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 gravatar imageJStarcher ( 2013-12-10 00:05:11 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-12-09 16:54:02 -0600

Seen: 705 times

Last updated: Dec 09 '13