note 98161 modified in memcache.getextendedstats by visualmind

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Get lists of all the keys stored in memcache server....

<?php
/**
 * Function to get all memcache keys
 * @author Manish Patel
 * @Created:  28-May-2010  
 */
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) {
				foreach($arrVal AS $k => $v) {					
					echo $k .'<br>';
				}
		   }
		}
	}	
}//EO getMemcacheKeys()
?>

Hope it helps....

--was--
Get lists of all the keys stored in memcache server....

/**
 * Function to get all memcache keys
 * @author Manish Patel
 * @Created:  28-May-2010  
 */
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) {
				foreach($arrVal AS $k => $v) {					
					echo $k .'<br>';
				}
		   }
		}
	}	
}//EO getMemcacheKeys()

Hope it helps....

http://php.net/manual/en/memcache.getextendedstats.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.