Class Horde_Lock_Sql
The Horde_Lock_Sql driver implements a storage backend for the Horde_Lock
API.
The table structure for the locks is as follows:
CREATE TABLE horde_locks (
lock_id VARCHAR(36) NOT NULL,
lock_owner VARCHAR(32) NOT NULL,
lock_scope VARCHAR(32) NOT NULL,
lock_principal VARCHAR(255) NOT NULL,
lock_origin_timestamp BIGINT NOT NULL,
lock_update_timestamp BIGINT NOT NULL,
lock_expiry_timestamp BIGINT NOT NULL,
lock_type TINYINT NOT NULL,
PRIMARY KEY (lock_id)
);
Copyright 2008-2012 Horde LLC (http://www.horde.org/)
See the enclosed file COPYING for license information (LGPL). If you did
not receive this file, see http://www.horde.org/licenses/lgpl21.
-
Horde_Lock
-
Horde_Lock_Sql
Methods summary
public
|
#
__construct( array $params = array() )
Constructor.
Parameters
- $params
- Parameters:
<pre><span class="php-quote">'db'</span> - (Horde_Db_Adapter) [REQUIRED] The DB instance.
<span class="php-quote">'table'</span> - (string) The name of the lock table in <span class="php-quote">'database'</span>.
<span class="php-keyword1">DEFAULT</span>: <span class="php-quote">'horde_locks'</span></pre>
Throws
Overrides
|
public
array
|
#
getLockInfo( string $lockid )
Return an array of information about the requested lock.
Return an array of information about the requested lock.
Parameters
- $lockid
- Lock ID to look up.
Returns
array Lock information.
Throws
See
Horde_Lock_Base::getLockInfo()
|
public
array
|
#
getLocks( string $scope = null, string $principal = null, integer $type = null )
Return a list of valid locks with the option to limit the results
by principal, scope and/or type.
Return a list of valid locks with the option to limit the results
by principal, scope and/or type.
Parameters
- $scope
- <p>The scope of the lock. Typically the name of
the application requesting the lock or some
other identifier used to group locks together.</p>
- $principal
- Principal for which to check for locks
- $type
- <p>Only return locks of the given type.
Defaults to null, or all locks</p>
Returns
array 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.
Throws
See
Horde_Lock_Base::getLocks()
|
public
boolean
|
#
resetLock( string $lockid, integer $extend )
Extend the valid lifetime of a valid lock to now + $newtimeout.
Extend the valid lifetime of a valid lock to now + $newtimeout.
Parameters
- $lockid
- <p>Lock ID to reset. Must be a valid, non-expired
lock.</p>
- $extend
- Extend lock this many seconds from now.
Returns
boolean Returns true on success.
Throws
See
Horde_Lock_Base::resetLock()
|
public
mixed
|
#
setLock( string $requestor, string $scope, string $principal, integer $lifetime = 1, string $type = Horde_Lock::TYPE_SHARED )
Sets a lock on the requested principal and returns the generated lock
ID.
Sets a lock on the requested principal and returns the generated lock
ID.
Parameters
- $requestor
- User ID of the lock requestor.
- $scope
- <p>The scope of the lock. Typically the name of
the application requesting the lock or some
other identifier used to group locks
together.</p>
- $principal
- <p>A principal on which a lock should be
granted. The format can be any string but is
suggested to be in URI form.</p>
- $lifetime
- <p>Time (in seconds) for which the lock will be
considered valid.</p>
- $type
- <p>One of Horde_Lock::TYPE_SHARED or
Horde_Lock::TYPE_EXCLUSIVE.
- An exclusive lock will be enforced strictly
and must be interpreted to mean that the
resource can not be modified. Only one
exclusive lock per principal is allowed.
- A shared lock is one that notifies other
potential lock requestors that the resource
is in use. This lock can be overridden
(cleared or replaced with a subsequent
call to setLock()) by other users. Multiple
users may request (and will be granted) a
shared lock on a given principal. All locks
will be considered valid until they are
cleared or expire.</p>
Returns
mixed A string lock ID.
Throws
See
Horde_Lock_Base::setLock()
|
public
boolean
|
#
clearLock( string $lockid )
Removes a lock given the lock ID.
Removes a lock given the lock ID.
Parameters
- $lockid
- <p>The lock ID as generated by a previous call
to setLock()</p>
Returns
boolean Returns true on success.
Throws
See
Horde_Lock_Base::clearLock()
|
public
|
#
doGC( )
Do garbage collection needed for the driver.
Do garbage collection needed for the driver.
|