You are here

public function MemCacheDrupal::lockInit in Memcache API and Integration 7

Helper function to load locking framework if not already loaded.

Return value

bool Whether the locking system was initialized successfully. This must always return TRUE or throw an exception.

1 call to MemCacheDrupal::lockInit()
MemCacheDrupal::valid in ./memcache.inc
Checks if a retrieved cache item is valid.

File

./memcache.inc, line 542

Class

MemCacheDrupal
Implementation of cache.inc with memcache logic included

Code

public function lockInit() {

  // On a cache miss when page_cache_without_database is enabled, we can end
  // up here without the lock system being initialized. Bootstrap drupal far
  // enough to load the lock system.
  if (!function_exists('lock_acquire')) {
    drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE);
  }
  if (!function_exists('lock_acquire')) {

    // Bootstrap failed, log error.
    register_shutdown_function('watchdog', 'memcache', 'Bootstrap failed in lockInit(), lock_acquire() is not available. (phase:!phase)', array(
      '!phase' => drupal_get_bootstrap_phase(),
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  return TRUE;
}