note 104459 added to memcache.getextendedstats
| From: | oushunbao at 163 dot com | Date: | Thu, 16 Jun 2011 09:57:20 +0000 |
| Subject: | note 104459 added to memcache.getextendedstats | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180599@lists.php.net to get a copy of this message | ||
Get lists of all the keys stored in memcache server....
<?php
/**
* Function to get all memcache keys
* @author Manish Patel
* @Created: 28-May-2010
* @modified: 16-Jun-2011
*/
function getMemcacheKeys() {
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect to memcache
server");
$list = array();
$allSlabs = $memcache->getExtendedStats('slabs');
$items = $memcache->getExtendedStats('items');
foreach($allSlabs as $server => $slabs) {
foreach($slabs AS $slabId => $slabMeta) {
$cdump = $memcache->getExtendedStats('cachedump',(int)$slabId);
foreach($cdump AS $keys => $arrVal) {
if (!is_array($arrVal)) continue;
foreach($arrVal AS $k => $v) {
echo $k .'<br>';
}
}
}
}
}//EO getMemcacheKeys()
?>
copy from up, but fix a warning
i only add one line: if (!is_array($arrVal)) continue;
----
Server IP: 69.147.83.197
Probable Submitter: 113.97.31.110
----
Manual Page -- http://www.php.net/manual/en/memcache.getextendedstats.php
Edit -- https://master.php.net/note/edit/104459
Del: integrated -- https://master.php.net/note/delete/104459/integrated
Del: useless -- https://master.php.net/note/delete/104459/useless
Del: bad code -- https://master.php.net/note/delete/104459/bad+code
Del: spam -- https://master.php.net/note/delete/104459/spam
Del: non-english -- https://master.php.net/note/delete/104459/non-english
Del: in docs -- https://master.php.net/note/delete/104459/in+docs
Del: other reasons-- https://master.php.net/note/delete/104459
Reject -- https://master.php.net/note/reject/104459
Search -- https://master.php.net/manage/user-notes.php