Not sure how to determine memcached's capacity (how full it is) using php. Can't seem to find any documentation on it either... Any ideas/suggestions?
Use getStats:
$m = new Memcached();
$m->addServer('localhost', 11211);
$stats = $m->getStats();
echo 'Capacity: ' . $stats['bytes'] . '/' . $stats['limit_maxbytes'] . ' Bytes';
I actually kept looking around - the more useful info can come from:
<?php
$memcache_obj = new Memcache;
$memcache_obj->addServer('memcache_host', 11211);
$memcache_obj->addServer('failed_host', 11211);
$stats = $memcache_obj->getExtendedStats('slabs');
print_r($stats);
?>
This actually outputs more relevant info based on the way memcached allocates memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With