You are here

protected function DriverBase::statsInit in Memcache API and Integration 8.2

Helper function to initialize the stats for a memcache operation.

9 calls to DriverBase::statsInit()
DriverBase::delete in src/Driver/DriverBase.php
Deletes an item from Memcache.
DriverBase::flush in src/Driver/DriverBase.php
Immediately invalidates all existing items.
DriverBase::get in src/Driver/DriverBase.php
Retrieves a value from Memcache.
MemcachedDriver::add in src/Driver/MemcachedDriver.php
Add an item to Memcache if it doesn't exist already.
MemcachedDriver::getMulti in src/Driver/MemcachedDriver.php
Retrieves multiple values from Memcache.

... See full list

File

src/Driver/DriverBase.php, line 286

Class

DriverBase
Class DriverBase.

Namespace

Drupal\memcache\Driver

Code

protected function statsInit() {
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast =& drupal_static(__FUNCTION__, [
      'variable_checked' => NULL,
      'user_access_checked' => NULL,
    ]);
  }
  $variable_checked =& $drupal_static_fast['variable_checked'];
  $user_access_checked =& $drupal_static_fast['user_access_checked'];

  // Confirm DRUPAL_BOOTSTRAP_VARIABLES has been reached. We don't use
  // drupal_get_bootstrap_phase() as it's buggy. We can use variable_get()
  // here because _drupal_bootstrap_variables() includes module.inc
  // immediately after it calls variable_initialize().
  // @codingStandardsIgnoreStart
  // if (!isset($variable_checked) && function_exists('module_list')) {
  //   $variable_checked = variable_get('show_memcache_statistics', FALSE);
  // }
  // If statistics are enabled we need to check user access.
  // if (!empty($variable_checked) && !isset($user_access_checked) && !empty($GLOBALS['user']) && function_exists('user_access')) {
  //   // Statistics are enabled and the $user object has been populated, so check
  //   // that the user has access to view them.
  //   $user_access_checked = user_access('access memcache statistics');
  // }
  // @codingStandardsIgnoreEnd
  // Return whether or not statistics are enabled and the user can access
  // them.
  if ((!isset($variable_checked) || $variable_checked) && (!isset($user_access_checked) || $user_access_checked)) {
    Timer::start('dmemcache');
    return TRUE;
  }
  else {
    return FALSE;
  }
}