Class: Doctrine_Locking_Manager_Pessimistic

Source Location: /Doctrine/Locking/Manager/Pessimistic.php

Class Doctrine_Locking_Manager_Pessimistic

Class Overview

Offline locking of records comes in handy where you need to make sure that a time-consuming task on a record or many records, which is spread over several page requests can't be interfered by other users.

Located in /Doctrine/Locking/Manager/Pessimistic.php [line 36]



		
				Author(s):
		
		
		
Information Tags:
Version:  $Revision: 1468 $
Link:  www.phpdoctrine.com
Since:  1.0
License:  LGPL

Properties

Methods

[ Top ]
Property Summary
Doctrine_Connection   $conn   The conn that is used by the locking manager
mixed   $_lockTable   The database table name for the lock tracking

[ Top ]
Method Summary
Doctrine_Locking_Manager_Pessimistic   __construct()   Constructs a new locking manager object
boolean   getLock()   Obtains a lock on a Doctrine_Record
mixed   getLockOwner()   Gets the identifier that identifies the owner of the lock on the given record.
integer   releaseAgedLocks()   Releases locks older than a defined amount of seconds
boolean   releaseLock()   Releases a lock on a Doctrine_Record
mixed   _getLockingUserIdent()   Gets the unique user identifier of a lock

[ Top ]
Properties
Doctrine_Connection   $conn [line 43]

The conn that is used by the locking manager

API Tags:
Access:  private


[ Top ]
mixed   $_lockTable = 'doctrine_lock_tracking' [line 47]

The database table name for the lock tracking

API Tags:
Access:  private


[ Top ]
Methods
Constructor __construct  [line 57]

  Doctrine_Locking_Manager_Pessimistic __construct( Doctrine_Connection $conn  )

Constructs a new locking manager object

When the CREATE_TABLES attribute of the connection on which the manager is supposed to work on is set to true, the locking table is created.

Parameters:
Doctrine_Connection   $conn:  The database connection to use

API Tags:
Access:  public


[ Top ]
getLock  [line 99]

  boolean getLock( Doctrine_Record $record, mixed $userIdent  )

Obtains a lock on a Doctrine_Record

Parameters:
Doctrine_Record   $record:  The record that has to be locked
mixed   $userIdent:  A unique identifier of the locking user

API Tags:
Return:  TRUE if the locking was successful, FALSE if another user holds a lock on this record
Access:  public

Information Tags:
Throws:  Doctrine_Locking_Exception If the locking failed due to database errors

[ Top ]
getLockOwner  [line 239]

  mixed getLockOwner( Doctrine_Record $lockedRecord  )

Gets the identifier that identifies the owner of the lock on the given record.

Parameters:
Doctrine_Record   $lockedRecord:  The record.

API Tags:
Return:  The unique user identifier that identifies the owner of the lock.
Access:  public


[ Top ]
releaseAgedLocks  [line 257]

  integer releaseAgedLocks( [integer $age = 900], [string $objectType = null], [mixed $userIdent = null]  )

Releases locks older than a defined amount of seconds

When called without parameters all locks older than 15 minutes are released.

Parameters:
integer   $age:  The maximum valid age of locks in seconds
string   $objectType:  The type of the object (component name)
mixed   $userIdent:  The unique identifier of the locking user

API Tags:
Return:  The number of locks that have been released
Access:  public

Information Tags:
Throws:  Doctrine_Locking_Exception If the release process failed due to database errors

[ Top ]
releaseLock  [line 168]

  boolean releaseLock( Doctrine_Record $record, mixed $userIdent  )

Releases a lock on a Doctrine_Record

Parameters:
Doctrine_Record   $record:  The record for which the lock has to be released
mixed   $userIdent:  The unique identifier of the locking user

API Tags:
Return:  TRUE if a lock was released, FALSE if no lock was released
Access:  public

Information Tags:
Throws:  Doctrine_Locking_Exception If the release procedure failed due to database errors

[ Top ]
_getLockingUserIdent  [line 205]

  mixed _getLockingUserIdent( string $objectType, mixed $key  )

Gets the unique user identifier of a lock

Parameters:
string   $objectType:  The type of the object (component name)
mixed   $key:  The unique key of the object

API Tags:
Return:  The unique user identifier for the specified lock
Access:  private

Information Tags:
Throws:  Doctrine_Locking_Exception If the query failed due to database errors

[ Top ]