Documentation

Horde_Lock
in package

The Horde_Lock class provides an API to create, store, check and expire locks based on a given resource URI.

Copyright 2008-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Tags
author

Ben Klang bklang@horde.org

category

Horde

Table of Contents

PERMANENT  = -1
TYPE_EXCLUSIVE  = 1
TYPE_SHARED  = 2
$_logger  : Horde_Log_Logger
Logger.
$_params  : array<string|int, mixed>
Driver parameters.
__construct()  : mixed
Constructor.
clearLock()  : bool
Removes a lock given the lock ID.
getLockInfo()  : array<string|int, mixed>
Return an array of information about the requested lock.
getLocks()  : array<string|int, mixed>
Return a list of valid locks with the option to limit the results by principal, scope and/or type.
resetLock()  : bool
Extend the valid lifetime of a valid lock to now + $extend.
setLock()  : mixed
Sets a lock on the requested principal and returns the generated lock ID. NOTE: No security checks are done in the Horde_Lock API. It is expected that the calling application has done all necessary security checks before requesting a lock be granted.

Constants

PERMANENT

public mixed PERMANENT = -1

TYPE_EXCLUSIVE

public mixed TYPE_EXCLUSIVE = 1

TYPE_SHARED

public mixed TYPE_SHARED = 2

Properties

$_logger

Logger.

protected Horde_Log_Logger $_logger

$_params

Driver parameters.

protected array<string|int, mixed> $_params

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $params = array() ]) : mixed
Parameters
$params : array<string|int, mixed> = array()

Configuration parameters:

'logger' - (Horde_Log_Logger) A logger instance.
Return values
mixed

clearLock()

Removes a lock given the lock ID.

public abstract clearLock(string $lockid) : bool

NOTE: No security checks are done in the Horde_Lock API. It is expected that the calling application has done all necessary security checks before requesting a lock be cleared.

Parameters
$lockid : string

The lock ID as generated by a previous call to setLock()

Tags
throws
Horde_Lock_Exception
Return values
bool

Returns true on success.

getLockInfo()

Return an array of information about the requested lock.

public abstract getLockInfo(string $lockid) : array<string|int, mixed>
Parameters
$lockid : string

Lock ID to look up.

Tags
throws
Horde_Lock_Exception
Return values
array<string|int, mixed>

Lock information.

getLocks()

Return a list of valid locks with the option to limit the results by principal, scope and/or type.

public abstract getLocks([string $scope = null ][, string $principal = null ][, int $type = null ]) : array<string|int, mixed>
Parameters
$scope : string = null

The scope of the lock. Typically the name of the application requesting the lock or some other identifier used to group locks together.

$principal : string = null

Principal for which to check for locks

$type : int = null

Only return locks of the given type. Defaults to null, or all locks

Tags
throws
Horde_Lock_Exception
Return values
array<string|int, mixed>

Array of locks with the ID as the key and the lock details as the value. If there are no current locks this will return an empty array.

resetLock()

Extend the valid lifetime of a valid lock to now + $extend.

public abstract resetLock(string $lockid, int $extend) : bool
Parameters
$lockid : string

Lock ID to reset. Must be a valid, non-expired lock.

$extend : int

Extend lock this many seconds from now.

Tags
throws
Horde_Lock_Exception
Return values
bool

Returns true on success.

setLock()

Sets a lock on the requested principal and returns the generated lock ID. NOTE: No security checks are done in the Horde_Lock API. It is expected that the calling application has done all necessary security checks before requesting a lock be granted.

public abstract setLock(string $requestor, string $scope, string $principal[, int $lifetime = 1 ][, mixed $exclusive = Horde_Lock::TYPE_SHARED ]) : mixed
Parameters
$requestor : string

User ID of the lock requestor.

$scope : string

The scope of the lock. Typically the name of the application requesting the lock or some other identifier used to group locks together.

$principal : string

A principal on which a lock should be granted. The format can be any string but is suggested to be in URI form.

$lifetime : int = 1

Time (in seconds) for which the lock will be considered valid.

$exclusive : mixed = Horde_Lock::TYPE_SHARED
Tags
throws
Horde_Lock_Exception
Return values
mixed

A string lock ID.

Search results