function dmemcache_stats in Memcache API and Integration 6
Same name and namespace in other branches
- 5.2 dmemcache.inc \dmemcache_stats()
- 5 dmemcache.inc \dmemcache_stats()
- 7 dmemcache.inc \dmemcache_stats()
3 calls to dmemcache_stats()
- memcache_admin_stats in memcache_admin/memcache_admin.module
- Memcahe Stats page
- memcache_admin_stats_raw in memcache_admin/memcache_admin.module
- theme_memcache_admin_stats_raw_table in memcache_admin/memcache_admin.module
1 string reference to 'dmemcache_stats'
- memcache_admin_requirements in memcache_admin/memcache_admin.install
- Implementation of hook_requirements().
File
- ./dmemcache.inc, line 501
Code
function dmemcache_stats($stats_bin = 'cache', $stats_type = 'default', $aggregate = FALSE) {
$memcache_bins = variable_get('memcache_bins', array(
'cache' => 'default',
));
if (!isset($memcache_bins['cache'])) {
$memcache_bins['cache'] = 'default';
}
$slab = (int) $stats_type;
$stats = array();
foreach ($memcache_bins as $bin => $target) {
if ($stats_bin == $bin) {
if ($mc = dmemcache_object($bin)) {
if ($mc instanceof Memcached) {
$stats[$bin] = $mc
->getStats();
}
else {
if ($mc instanceof Memcache) {
if ($stats_type == 'default' || $stats_type == '') {
$stats[$bin] = $mc
->getExtendedStats();
}
else {
if (!empty($slab)) {
$stats[$bin] = $mc
->getStats('cachedump', $slab);
}
else {
$stats[$bin] = $mc
->getExtendedStats($stats_type);
}
}
}
}
}
}
}
if ($aggregate) {
$no_aggregate = array(
'pid',
'time',
'version',
'pointer_size',
'accepting_conns',
'listen_disabled_num',
);
foreach ($stats as $bin => $servers) {
if (is_array($servers)) {
foreach ($servers as $server) {
if (is_array($server)) {
foreach ($server as $key => $value) {
if (!in_array($key, $no_aggregate)) {
if (isset($stats[$bin]['total'][$key])) {
$stats[$bin]['total'][$key] += $value;
}
else {
$stats[$bin]['total'][$key] = $value;
}
}
}
}
}
}
}
}
return $stats;
}