//Redis$redis=NewRedis ();$redis->connect ("host", "Port");$redis->select (0);//Redis defaults to 0-15 16 databases select 0 here$redis->dbsize ();//returns the number of keys$keys=$redis->keys ("*");//list all keys by using a wildcard characterVar_dump($keys);//memcache$servers=Array(Array("Host1", "Port1"),Array("Host2", "Port2"));$mem=NewMemcache ();$mem->addserver ("Host1", "Port1");$mem->addserver ("Host2", "Port2");$all _items=$memcache->getextendedstats (' Items ');$options=Array("Host1:port1", "Host2:port2");
foreach($servers as $server){ $option=$server[0]. ":" .$server[1]; if(isset($all _items[$option[' Items '])) { $items=$all _items[$option[' Items ']; foreach($items as $number=$item) { $str=$memcache->getextendedstats (' Cachedump ',$number, 0); $line=$str[$option]; if(Is_array($line) &&Count($line) > 0){ foreach($line as $key=$value) { $keys[] =$key; } } } }}Var_dump($keys);
Redis and memcache list all keys