Search code examples
djangomemcacheddjango-sessions

Sessions on Memcached in Django - no items in Memcached


I'm setting up sessions in Django using memcached, and after logging in, no items appear in the cache.

I can connect to my memcached instance with telnet localhost 11211 and stats says the process is running. My cache settings are as follows:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': '127.0.0.1:11211' # can also be a list of locations
    }
}
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'

and I do have the database set up for the caching. The sessions show up in the database. (when using just backends.cache nothing shows up in the database or the cache.)

So is this the expected behavior? Do I have to store something special in the session key for it to register?


Solution

  • I'm using 1.2 and was reading the docs for 1.3.

    In 1.2, the cache looks like this: CACHE_BACKEND = "memcached://127.0.0.1:11211/" instead of the caches dictionary.