I would like to export all keys and values from a memcached server, using python-memcache. There is no such function in that module. How to do it then?
Perhaps something more complicated involving the "socket" module would be needed.
In short, to list all keys in Memcached, we obtain the slab ID then list the keys using stats cachedump command.
Memcache::get() returns previously stored data of an item, if such key exists on the server at this moment. You can pass array of keys to Memcache::get() to get array of values. The result array will contain only found key-value pairs.
This page provides Python code examples for using memcache. Memcache is a high-performance, distributed memory object caching system that provides fast access to cached data. To learn more about memcache, read the Memcache Overview. This page describes how to use the legacy bundled services and APIs.
For example, the total number of items (i.e. key-value pairs) stored in Memcached, can be useful information to move forward. The total number of items stored in Memcached is 10.
The easiest way is to use python-memcached-stats package, https://github.com/abstatic/python-memcached-stats
The keys() method should get you going.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With