You are here

function dmemcache_stats_write in Memcache API and Integration 6

Same name and namespace in other branches
  1. 7 dmemcache.inc \dmemcache_stats_write()

Save memcache statistics to be displayed at end of page generation.

Parameters

string $action: The action being performed (get, set, etc...).

string $bin: The memcache bin the action is being performed in.

array $keys: Keyed array in the form (string)$cid => (bool)$success. The keys the action is being performed on, and whether or not it was a success.

6 calls to dmemcache_stats_write()
dmemcache_add in ./dmemcache.inc
Add an item into memcache
dmemcache_delete in ./dmemcache.inc
Deletes an item from the cache.
dmemcache_flush in ./dmemcache.inc
Immediately invalidates all existing items. dmemcache_flush doesn't actually free any resources, it only marks all the items as expired, so occupied memory will be overwritten by new items.
dmemcache_get in ./dmemcache.inc
Retrieve a value from the cache.
dmemcache_get_multi in ./dmemcache.inc
Retrieve multiple values from the cache.

... See full list

File

./dmemcache.inc, line 917

Code

function dmemcache_stats_write($action, $bin, $keys) {
  global $_dmemcache_stats;

  // Determine how much time elapsed to execute this action.
  $time = timer_read('dmemcache');

  // Build the 'all' and 'ops' arrays displayed by memcache_admin.module.
  foreach ($keys as $key => $success) {
    $_dmemcache_stats['all'][] = array(
      number_format($time, 2),
      $action,
      $bin,
      $key,
      $success ? 'hit' : 'miss',
    );
    if (!isset($_dmemcache_stats['ops'][$action])) {
      $_dmemcache_stats['ops'][$action] = array(
        $action,
        0,
        0,
        0,
      );
    }
    $_dmemcache_stats['ops'][$action][1] += $time;
    if ($success) {
      $_dmemcache_stats['ops'][$action][2]++;
    }
    else {
      $_dmemcache_stats['ops'][$action][3]++;
    }
  }

  // Reset the dmemcache timer for timing the next memcache operation.
}