You are here

function _memcache_admin_stats_gets in Memcache API and Integration 7

Same name and namespace in other branches
  1. 6 memcache_admin/memcache_admin.module \_memcache_admin_stats_gets()

Statistics report: calculate # of get cmds, broken down by hits and misses.

1 call to _memcache_admin_stats_gets()
memcache_admin_stats in memcache_admin/memcache_admin.module
Callback for the Memcache Stats page.

File

memcache_admin/memcache_admin.module, line 164
For the collection and display of memcache stats.

Code

function _memcache_admin_stats_gets($stats) {
  if ($stats['cmd_set'] + $stats['cmd_get'] == 0) {
    $gets = 0;
  }
  else {
    $gets = $stats['cmd_get'] / ($stats['cmd_set'] + $stats['cmd_get']) * 100;
  }
  if (empty($stats['uptime'])) {
    $average = 0;
  }
  else {
    $average = $stats['cmd_get'] / $stats['uptime'];
  }
  return t('!average/s; !total gets (!gets%); !hit hits (!percent_hit%) !miss misses (!percent_miss%)', array(
    '!average' => number_format($average, 2),
    '!gets' => number_format($gets, 2),
    '!hit' => number_format($stats['get_hits']),
    '!percent_hit' => $stats['cmd_get'] > 0 ? number_format($stats['get_hits'] / $stats['cmd_get'] * 100, 2) : '0.00',
    '!miss' => number_format($stats['get_misses']),
    '!percent_miss' => $stats['cmd_get'] > 0 ? number_format($stats['get_misses'] / $stats['cmd_get'] * 100, 2) : '0.00',
    '!total' => number_format($stats['cmd_get']),
  ));
}