You are here

function memcache_admin_menu in Memcache API and Integration 5.2

Same name and namespace in other branches
  1. 5 memcache_admin/memcache_admin.module \memcache_admin_menu()
  2. 6 memcache_admin/memcache_admin.module \memcache_admin_menu()
  3. 7 memcache_admin/memcache_admin.module \memcache_admin_menu()

File

memcache_admin/memcache_admin.module, line 3

Code

function memcache_admin_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/memcache',
      'callback' => 'memcache_admin_stats',
      'title' => t('Memcache'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'access' => user_access('access memcache statistics'),
      'description' => t("View the statistics for this site's memcache and generate new settings."),
    );
  }
  else {
    $memache_servers = variable_get('memcache_servers', array());
    $clusters = array();
    foreach ($memache_servers as $server => $cluster) {
      $clusters[$cluster]['servers'][] = $server;
      $clusters[$cluster]['bin'] = _memcache_admin_get_bin_for_cluster($cluster);
    }
    $count = 0;
    foreach ($clusters as $cluster => $cluster_info) {
      if ($cluster_info['bin']) {
        $items[] = array(
          'path' => 'admin/settings/memcache/' . $cluster,
          'type' => MENU_LOCAL_TASK,
          'callback' => 'memcache_admin_stats',
          'callback arguments' => array(
            $cluster,
          ),
          'title' => $cluster,
          'access' => user_access('access memcache statistics'),
          'weight' => $count,
        );
        $count++;
      }
    }
    if ($arg = arg(3)) {
      $count = 0;
      foreach (array(
        'default',
        'reset',
        'malloc',
        'maps',
        'cachedump',
        'slabs',
        'items',
        'sizes',
      ) as $type) {
        $items[] = array(
          'path' => 'admin/settings/memcache/' . $arg . '/' . $type,
          'type' => $type == 'default' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
          'callback' => 'memcache_admin_stats',
          'callback arguments' => array(
            $arg,
            $type,
          ),
          'title' => $type,
          'access' => user_access('access memcache statistics'),
          'weight' => $count,
        );
        $count++;
      }
    }
  }
  return $items;
}