9👍
✅
Django prefixes cache keys with a colon. You can inspect memcached like so if this doesn’t help.
5👍
You can use memcached_stats from:
https://github.com/dlrust/python-memcached-stats
Example:
(I used pylibmc for the cache, but I think this should be the same is you use python-memcached)
import pylibmc
from memcached_stats import MemcachedStats
mem = MemcachedStats() # connecting to localhost at default memcached port
# print out all your keys
mem.keys()
# say for example key[0] is 'countries', then to get the value just do
key = mem.keys()[0]
import memcache
mc = memcache.Client(['127.0.0.1:11211'], debug=1)
value = mc.get (key)
There is also a command line interface to memcaced_stats:
python -m memcached_stats
Have a look at the github repo as the README is very clear.
- How do I memoize expensive calculations on Django model objects?
- Django ALLOWED_HOSTS for Amazon ELB
- Can I slow down Django
- Differences between `class` and `def`
3👍
The following script dumps all the keys of a memcached server. It’s tested with Ubuntu 12.04 and a localhost memcached, so your milage may vary.
#!/usr/bin/env bash
echo 'stats items' \
| nc localhost 11211 \
| grep -oe ':[0-9]*:' \
| grep -oe '[0-9]*' \
| sort \
| uniq \
| xargs -L1 -I{} bash -c 'echo "stats cachedump {} 1000" | nc localhost 11211'
What it does, it goes through all the cache slabs and print 1000 keys of each.
Source:stackexchange.com