FileLockStrategy implements LockingStrategyInterface uses BlockSerializationTrait

flock() locking

Table of Contents

Interfaces

LockingStrategyInterface
Interface for locking methods

Constants

DEFAULT_PRIORITY  = 75
FILE_LOCK_FOLDER  = 'lock/'

Properties

$filePath  : string
$filePointer  : resource
$isAcquired  : bool

Methods

__construct()  : mixed
__destruct()  : mixed
Destructor: Releases lock automatically when instance is destroyed and release resources
__wakeup()  : mixed
Deny object deserialization.
acquire()  : bool
Try to acquire an exclusive lock
destroy()  : mixed
Destroys the resource associated with the lock
getCapabilities()  : int
getPriority()  : int
isAcquired()  : bool
Get status of this lock
release()  : bool
Release the lock

Constants

DEFAULT_PRIORITY

public mixed DEFAULT_PRIORITY = 75

FILE_LOCK_FOLDER

public mixed FILE_LOCK_FOLDER = 'lock/'

Properties

$filePath

protected string $filePath

File used for locking

$filePointer

protected resource $filePointer

File pointer if using flock method

$isAcquired

protected bool $isAcquired = false

True if lock is acquired

Methods

__construct()

public __construct(string $subject) : mixed
Parameters
$subject : string

ID to identify this lock in the system

Tags
throws
LockCreateException

if the lock could not be created

__destruct()

Destructor: Releases lock automatically when instance is destroyed and release resources

public __destruct() : mixed

__wakeup()

Deny object deserialization.

public __wakeup() : mixed

acquire()

Try to acquire an exclusive lock

public acquire([int $mode = self::LOCK_CAPABILITY_EXCLUSIVE ]) : bool
Parameters
$mode : int = self::LOCK_CAPABILITY_EXCLUSIVE

LOCK_CAPABILITY_EXCLUSIVE or LOCK_CAPABILITY_SHARED or self::LOCK_CAPABILITY_NOBLOCK

Tags
throws
LockAcquireException

if the lock could not be acquired

throws
LockAcquireWouldBlockException

if the acquire would have blocked and NOBLOCK was set

Return values
bool

Returns TRUE if the lock was acquired successfully

destroy()

Destroys the resource associated with the lock

public destroy() : mixed

getCapabilities()

public static getCapabilities() : int
Return values
int

LOCK_CAPABILITY_* elements combined with bit-wise OR

getPriority()

public static getPriority() : int
Return values
int

Returns a priority for the method. 0 to 100, 100 is highest

isAcquired()

Get status of this lock

public isAcquired() : bool
Return values
bool

Returns TRUE if lock is acquired by this locker, FALSE otherwise

release()

Release the lock

public release() : bool
Return values
bool

Returns TRUE on success or FALSE on failure


        
On this page

Search results