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?
相关问题
- Django __str__ returned non-string (type NoneType)
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Django restrict pages to certain users
- UnicodeEncodeError with attach_file on EmailMessag
相关文章
- Profiling Django with PyCharm
- Why doesn't Django enforce my unique_together
- MultiValueDictKeyError in Django admin
- Django/Heroku: FATAL: too many connections for rol
- Why is file_get_contents faster than memcache_get?
- Django is sooo slow? errno 32 broken pipe? dcramer
- Django: Replacement for the default ManyToMany Wid
- Upgrading transaction.commit_manually() to Django
You can test memcached or any server by below script
if it returns 0 then the server is actually running or if 1 its not so if you want to know that the server is actually running on some port use the following script
Simple way to test for memcache working was to sneak in a commented out timestamp on every page served up. If the timestamp stayed the same on multiple requests to a page, then the page was being cached by memcache.
In Django settings, I also setup the cache mechanism to use a file cache on the filesystem (really slow), but after hitting up the pages I could see that there were actual cache files being placed in the file path so I could confirm caching was active in Django.
I used both these steps to work out my caching problem. I actually did not have caching turned on correctly in Django. The newer method to activate caching is using the 'django.middleware.cache.CacheMiddleware' middleware (not the middleware with two middleware pieces that have to be the first/last middleware settings.)
For extend Node's response, you can use
socat UNIX-CONNECT:/var/run/memcached.sock STDIN
to debug a unix socket.Example:
Following Aryashree post, this helped me to get an error if memcached not running locally:
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):
To test your django cache config, you can use the low-level cache api.
First, start up the python interpreter and load your django project settings:
From the shell, you can use the low-level cache api to test your memcache server:
If your cache configuration is correct, you should see output in memcache similar to this:
In Bash, you can check the statistics of memcache by this command:
To flush the cache, use
memflush
command:and check if the stats increased.
To dump all the cached objects, use
memdump
command (part ofmemcached
/libmemcached
package):If you're using PHP, to see whether is supported, check by:
php -i | grep memcached
.Tracing
To check what memcached process is exactly processing, you can use network sniffers or debuggers (e.g.
strace
on Linux ordtrace
/dtruss
on Unix/OS X) for that. Check some examples below.Strace
To format output in a better way, check: How to parse strace in shell into plain text?
Dtruss
Dtruss is a dtrace wrapper which is available on Unix systems. Run it as:
Tcpdump