You are here

class Redis_Lock in Redis 7

Same name and namespace in other branches
  1. 7.3 lib/Redis/Lock.php \Redis_Lock
  2. 7.2 lib/Redis/Lock.php \Redis_Lock

Lock backend singleton handling.

Hierarchy

Expanded class hierarchy of Redis_Lock

File

lib/Redis/Lock.php, line 6

View source
class Redis_Lock {

  /**
   * @var Redis_Lock_Backend_Interface
   */
  private static $__instance;

  /**
   * Set the current lock backend.
   *
   * @param Redis_Lock_Backend_Interface $lockBackend
   */
  public static function setBackend(Redis_Lock_Backend_Interface $lockBackend) {
    if (isset(self::$__instance)) {
      throw new Exception("Lock backend already set, changing it would cause already acquired locks to stall.");
    }
    self::$__instance = $lockBackend;
  }

  /**
   * Get actual lock backend.
   *
   * @return Redis_Lock_Backend_Interface
   */
  public static function getBackend() {
    if (!isset(self::$__instance)) {
      throw new Exception("No lock backend set.");
    }
    return self::$__instance;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Redis_Lock::$__instance private static property
Redis_Lock::getBackend public static function Get actual lock backend.
Redis_Lock::setBackend public static function Set the current lock backend.