paradox870
paradox870

Reputation: 2202

How to check memcached's capacity using php

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?

Upvotes: 3

Views: 2169

Answers (2)

paradox870
paradox870

Reputation: 2202

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.

Upvotes: 2

phihag
phihag

Reputation: 287835

Use getStats:

$m = new Memcached();
$m->addServer('localhost', 11211);

$stats = $m->getStats();
echo 'Capacity: ' . $stats['bytes'] . '/' . $stats['limit_maxbytes'] . ' Bytes';

Upvotes: 3

Related Questions