How do you know if memcached is doing anything?

MikeN picture MikeN · Mar 10, 2009 · Viewed 72.6k times · Source

I'm testing out using memcached to cache django views. How can I tell if memcached is actually caching anything from the Linux command line?

Answer

lettertwo picture lettertwo · Aug 9, 2011

I know this question is old, but here is another useful approach for testing memcached with django:

As @Jacob mentioned, you can start memcached in very verbose mode (not as a daemon):

memcached -vv

To test your django cache config, you can use the low-level cache api.

  1. First, start up the python interpreter and load your django project settings:

    python manage.py shell
    
  2. From the shell, you can use the low-level cache api to test your memcache server:

    from django.core.cache import cache
    cache.set('test', 'test value')
    

If your cache configuration is correct, you should see output in memcache similar to this:

<32 set :1:test 0 300 10
>32 STORED