First time here? Check out the FAQ!
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?

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
mattbenh's avatar
15
mattbenh
asked 11 years ago

Comments

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

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
JStarcher's avatar
71
JStarcher
answered 11 years ago
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 (11 years ago)
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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
answered 11 years ago
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 (11 years ago)

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 (11 years ago)
see more comments