note 102495 deleted from memcache.getextendedstats by danbrown

From: Date: Thu, 17 Feb 2011 16:08:46 +0000
Subject: note 102495 deleted from memcache.getextendedstats by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-177076@lists.php.net to get a copy of this message
Note Submitter: vasiliy dott dolgov att gmail dott com ---- Thanks to manmca. I use more simple code for single-server configuration. <?php /* OO style */ class MyMemcache extends Memcache{ public function getAllKeys(){ $keys = array(); foreach(array_keys($this->getStats('slabs')) as $slab){ $cdump = $this->getStats('cachedump',$slab); $keys = !is_null($cdump) ? $keys + array_keys($cdump) : $keys; } return $keys; } } $m = new MyMemcache(); $m->connect('127.0.0.1', 11211); $keys = $m->getAllKeys(); print_r($keys); /* Procedural style */ function memcache_get_all_keys($obj){ $keys = array(); foreach(array_keys(memcache_get_stats($obj,'slabs')) as $slab){ $cdump = memcache_get_stats($obj,'cachedump',$slab); $keys = !is_null($cdump) ? $keys + array_keys($cdump) : $keys; } return $keys; } $m_obj = memcache_connect('127.0.0.1', 11211); $keys = memcache_get_all_keys($m_obj); print_r($keys);

« previous php.notes (#177076) next »