I have my own function. I hope this is work for you. While, I'm typing this, I did not directly testing it. So, If you found the bug. Report it by commenting below.
function get_memcache_keys($host = '127.0.0.1', $port = 11211) { $memcache = new Memcache; $memcache->connect($host, $port) 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) { $return[] = $k; } } } } if(is_array($return)) { return $return; } else { return ''; } } function empty_memcache_data($host = '127.0.0.1', $port = 11211) { $memcache = new Memcache; $memcache->connect($host, $port) or die ("Could not connect to memcache server"); $keys = get_memcache_key($host, $port); if(is_array($keys)) { foreach($keys as $k) { $memcache->delete($k); } } } empty_memcache_data();
Next, I will write down how to empty memcache data / delete all memcache data by specific namespace. See you ;)
PS: Sorry for my english and bad grammar. Actually, I am not native English speaker. If you have an errata, please free to correct it.
or maybe just use $memcache->flush();
ReplyDeletelol
Deletethat does not delete the data though
Delete