djangomemcachedpython-memcached

django and memcached - what is actually being cached?


It could be that I'm just expecting too much from django caching but just in case I'm missing something here it is.

I've installed memcached (memcached, libmemcached and python-memcached) and configured it as per this instruction.

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    }
}

so I started memcached and restarted the application server but django doesn't seem to use memcached.

stats (over 11211 port)
STAT pid 30582
STAT uptime 6574
STAT time 1331463502
STAT version 1.4.13
STAT libevent 2.0.17-stable
STAT pointer_size 32
STAT rusage_user 0.000000
STAT rusage_system 0.180011
STAT curr_connections 5
STAT total_connections 11
STAT connection_structures 6
STAT reserved_fds 20
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 81
STAT bytes_written 5172
STAT limit_maxbytes 16777216
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 262144
STAT hash_is_expanding 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT evictions 0
STAT reclaimed 0
END

Solution

  • Declaring a cache does not actually use it. The Django documentation points out various ways in which you can configure Django to use the cache, or explicitly use it in your code and templates.