Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
957 views
in Technique[技术] by (71.8m points)

django - How do you know if memcached is doing anything?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...