PHP 7.2.0 Beta 1 Released


(PECL memcached >= 2.0.0)

Memcached::getAllKeysGets the keys stored on all the servers


public array Memcached::getAllKeys ( void )

Memcached::getAllKeys() queries each memcache server and retrieves an array of all keys stored on them at that point in time. This is not an atomic operation, so it isn't a truly consistent snapshot of the keys at point in time. As memcache doesn't guarantee to return all keys you also cannot assume that all keys have been returned.

Elenco dei parametri

Questa funzione non contiene parametri.

Valori restituiti

Returns the keys stored on all the servers on success o FALSE in caso di fallimento.

add a note add a note

User Contributed Notes 4 notes

flaviu dot chelaru at gmail dot com
5 months ago
// initiate the memcached instance
$cache = new \Memcached();
$cache->addServer('localhost', '11211');

// get all stored memcached items

$keys = $cache->getAllKeys();

$store = $cache->fetchAll();

// delete by regex keys

$keys = $cache->getAllKeys();
$regex = 'product_.*';
foreach($keys as $item) {
    if(preg_match('/'.$regex.'/', $item)) {
xiangku7890 at gmail dot com
1 year ago
First I use the lastest memcached version 1.4.25, but unfortunately I found memcached::getAllkeys do not work with it, though i follow the others suggestion to disable Memcached::OPT_BINARY_PROTOCOL. So i try to use history versions, when i use memcached version 1.4.17, it works.
fykknd at 163 dot com
1 year ago
I got this answer..
My libmemcached version is 1.0.18. php-memcached version is 2.2.0
In Libmemcached at memcache.h line 84:
Modify it to 201, compile again. It's ok.
2 years ago
This command returns always FALSE when binary protocol in use (Memcached::OPT_BINARY_PROTOCOL = true). Without binary protocol it works.
To Top