You are here

redis.lock.inc in Redis 7.3

Same filename and directory in other branches
  1. 7 redis.lock.inc
  2. 7.2 redis.lock.inc

Drupal core lock.inc replacement.

Do not use this file directly, it will be included by the backend specific implementation when added to settings.php file.

See README.txt file for details.

File

redis.lock.inc
View source
<?php

/**
 * @file
 * Drupal core lock.inc replacement.
 * 
 * Do not use this file directly, it will be included by the backend specific
 * implementation when added to settings.php file.
 * 
 * See README.txt file for details.
 */

// Include our own autoloader to ensure classes to be there.
// We cannot rely on core in case of early bootstrap phases.
require_once dirname(__FILE__) . '/redis.autoload.inc';

/**
 * Foo function, keeping it for API consistency (Drupal 7).
 */
function lock_initialize() {
}

/**
 * Foo function, keeping it for API consistency (Drupal 6).
 */
function lock_init() {
}

/**
 * Foo function, keeping it for API consistency.
 * Some insane people may actually use it.
 */
function _lock_id() {
  return Redis_Lock::getBackend()
    ->getLockId();
}
function lock_acquire($name, $timeout = 30.0) {
  return Redis_Lock::getBackend()
    ->lockAcquire($name, $timeout);
}
function lock_may_be_available($name) {
  return Redis_Lock::getBackend()
    ->lockMayBeAvailable($name);
}
function lock_wait($name, $delay = 30) {
  return Redis_Lock::getBackend()
    ->lockWait($name, $delay);
}
function lock_release($name) {
  return Redis_Lock::getBackend()
    ->lockRelease($name);
}
function lock_release_all($lock_id = NULL) {
  return Redis_Lock::getBackend()
    ->lockReleaseAll($lock_id);
}

// Since D6 doesn't have the drupal_register_shutdown_function
// that is called in lib/Redis/Lock/Backend/Default.php define
// the wrapper here.
if (!function_exists('drupal_register_shutdown_function')) {
  function drupal_register_shutdown_function() {
    $args = func_get_args();
    call_user_func_array('register_shutdown_function', $args);
  }
}

Functions

Namesort descending Description
lock_acquire
lock_init Foo function, keeping it for API consistency (Drupal 6).
lock_initialize Foo function, keeping it for API consistency (Drupal 7).
lock_may_be_available
lock_release
lock_release_all
lock_wait
_lock_id Foo function, keeping it for API consistency. Some insane people may actually use it.