Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export all keys and values from memcached with python-memcache?

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.

like image 760
Falken Avatar asked Apr 20 '11 12:04

Falken


People also ask

How do I list all Memcached keys?

In short, to list all keys in Memcached, we obtain the slab ID then list the keys using stats cachedump command.

How do I get data from memcache?

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.

What is memcache in Python?

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.

How many key-value pairs are stored on the Memcached server?

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.


1 Answers

The easiest way is to use python-memcached-stats package, https://github.com/abstatic/python-memcached-stats

The keys() method should get you going.

like image 87
abhishek_M Avatar answered Sep 18 '22 08:09

abhishek_M