FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Lock Class Reference
Inheritance diagram for Lock:
Component Thing

Public Member Functions

 ping ()
 
 purge ()
 Purge old locks. More...
 
 exists ($item, $id=null, $user=null)
 Check wether a lock exists. More...
 
 request ($item, $id=null)
 Request a lock on an item. More...
 
 refresh ($item=null, $id=null)
 Refresh one or multiple lock(s). More...
 
 release ($item=null, $id=null)
 Release one or multiple lock(s). More...
 
 owner ($item, $id=null)
 Who owns a lock. More...
 
- Public Member Functions inherited from Component
 __construct ($fred, $config=null)
 
 __destruct ()
 
 clientConfig ()
 Public configuration. More...
 
 config ($key, $default=null)
 Retrieve a config value. More...
 
 ping ()
 Ping function. More...
 
 filemtime ($filename)
 Filemtime with session cache. More...
 
 component ($name)
 Get a component (local or default). More...
 
 components (... $names)
 Get multiple components in an array. More...
 
- Public Member Functions inherited from Thing
 propertyExists ($property)
 Check if a property exists (public or published). More...
 
 constants ($prefix=null)
 Return all constants. More...
 
 get ($key)
 Get one or more properties. More...
 
 set ($key, $value=null)
 Set one or more properties. More...
 
 __get ($key)
 
 __set ($key, $value)
 

Data Fields

 $keySeperator = '_'
 String to seperate key info with (may not be present in item type or ID). More...
 
 $multiIndicator = '-----'
 String to indicate a lock for all ID's of an item type. More...
 
 $ext = '.lock'
 Extension for lock file. More...
 
- Data Fields inherited from Component
 $filemtimeTtl = 0
 
- Data Fields inherited from Thing
const HIDDEN = 0
 Property is hidden. More...
 
const READABLE = 1
 Property is readable. More...
 
const WRITEABLE = 2
 Property is writeable. More...
 
const READWRITE = 3
 Property is readable and writeable. More...
 

Protected Member Functions

 key ($item, $id, $user=null)
 Generate a lock key. More...
 
 filename ($item, $id, $user=null)
 Filename for a lock file. More...
 
 find ($item=null, $id=null, $user=null)
 Find lock files. More...
 
 getPath ()
 
 getTimeout ()
 
- Protected Member Functions inherited from Component
 init ()
 
 done ()
 
 getSession ()
 
- Protected Member Functions inherited from Thing
 publish ($property, $visibility=self::READABLE)
 Publish a property (or hide it again). More...
 
 configure ($config)
 Configure the object. More...
 
 _get ($key)
 Default getter if no specific setter is defined, and the property is also not published (readable). More...
 
 _set ($key, $value)
 Default setter if no specific setter is defined, and the property is also not published (writeable). More...
 

Protected Attributes

 $_timeout = null
 Number of seconds after which a lock expires (empty = use double of. More...
 
 $_path = null
 Path to store the lock files (temp path if empty). More...
 
- Protected Attributes inherited from Component
 $_fred = null
 
 $_config = null
 
 $_name = null
 
 $_components = []
 Local components (key = component name, value = component). More...
 
 $_session = null
 
- Protected Attributes inherited from Thing
 $_published = []
 Published properties (key = name of property, value = visibility). More...
 

Detailed Description

Definition at line 5 of file Lock.php.

Member Function Documentation

◆ exists()

exists (   $item,
  $id = null,
  $user = null 
)

Check wether a lock exists.

Parameters
string$itemItem type.
mixed$idID of the item (empty = check for all items lock).
mixed$userUser ID of the owner (all users when empty; use false to exclude own locks).
Returns
int Number of active locks (should be 0 or 1, but in a race condition it could be more).

Definition at line 63 of file Lock.php.

◆ filename()

filename (   $item,
  $id,
  $user = null 
)
protected

Filename for a lock file.

Parameters
string$itemItem type.
mixed$idId of the item (true = all ID's).
mixed$userUser ID of the owner (current user when empty).
Returns
string

Definition at line 37 of file Lock.php.

◆ find()

find (   $item = null,
  $id = null,
  $user = null 
)
protected

Find lock files.

Parameters
string$itemItem type (empty = return all locks for this user).
mixed$idID of the item (empty = return all locks for this item type).
mixed$userUser ID of the owner (current user when empty).
Returns
array Lock filenames.

Definition at line 47 of file Lock.php.

◆ getPath()

getPath ( )
protected

Definition at line 133 of file Lock.php.

◆ getTimeout()

getTimeout ( )
protected

Definition at line 138 of file Lock.php.

◆ key()

key (   $item,
  $id,
  $user = null 
)
protected

Generate a lock key.

Parameters
string$itemItem type.
mixed$idId of the item.
mixed$userUser ID of the owner (current user when empty).
Returns
string

Definition at line 27 of file Lock.php.

◆ owner()

owner (   $item,
  $id = null 
)

Who owns a lock.

Parameters
string$itemItem type.
mixed$idID of the item.
Returns
mixed User ID of the owner (false when not locked).

Definition at line 127 of file Lock.php.

◆ ping()

ping ( )

Definition at line 16 of file Lock.php.

◆ purge()

purge ( )

Purge old locks.

Definition at line 53 of file Lock.php.

◆ refresh()

refresh (   $item = null,
  $id = null 
)

Refresh one or multiple lock(s).

Parameters
string$itemItem type (empty = refresh all locks for this user).
mixed$idID of the item (empty = refresh all locks for this item type).
Returns
bool True on success.

Definition at line 101 of file Lock.php.

◆ release()

release (   $item = null,
  $id = null 
)

Release one or multiple lock(s).

Parameters
string$itemItem type (empty = release all locks for this user).
mixed$idID of the item (empty = release all locks for this item type).
Returns
bool True on success.

Definition at line 116 of file Lock.php.

◆ request()

request (   $item,
  $id = null 
)

Request a lock on an item.

Parameters
string$itemItem type.
mixed$idID of the item (empty = lock all items).
Returns
bool True on success.

Definition at line 77 of file Lock.php.

Field Documentation

◆ $_path

$_path = null
protected

Path to store the lock files (temp path if empty).

Definition at line 14 of file Lock.php.

◆ $_timeout

$_timeout = null
protected

Number of seconds after which a lock expires (empty = use double of.

Definition at line 12 of file Lock.php.

◆ $ext

$ext = '.lock'

Extension for lock file.

Definition at line 10 of file Lock.php.

◆ $keySeperator

$keySeperator = '_'

String to seperate key info with (may not be present in item type or ID).

Definition at line 7 of file Lock.php.

◆ $multiIndicator

$multiIndicator = '-----'

String to indicate a lock for all ID's of an item type.

Definition at line 8 of file Lock.php.


The documentation for this class was generated from the following file: