\ActionScheduler_Lock

Abstract class for setting a basic lock to throttle some action.

Class ActionScheduler_Lock

Summary

Methods
Properties
Constants
is_locked()
set()
get_expiration()
instance()
No public properties found
No constants found
get_duration()
$lock_duration
N/A
No private methods found
$locker
N/A

Properties

$lock_duration

$lock_duration : int

Duration of lock.

Type

normal

$locker

$locker : \ActionScheduler_Lock

Instance.

Type

normal

Methods

is_locked()

is_locked(string  $lock_type) : bool

Check if a lock is set for a given lock type.

Parameters

string $lock_type

A string to identify different lock types.

Returns

bool

set()

set(string  $lock_type) : bool

Set a lock.

To prevent race conditions, implementations should avoid setting the lock if the lock is already held.

Parameters

string $lock_type

A string to identify different lock types.

Returns

bool

get_expiration()

get_expiration(string  $lock_type) : bool|int

If a lock is set, return the timestamp it was set to expiry.

Parameters

string $lock_type

A string to identify different lock types.

Returns

bool|int —

False if no lock is set, otherwise the timestamp for when the lock is set to expire.

instance()

instance() : \ActionScheduler_Lock

Get instance.

Returns

\ActionScheduler_Lock

get_duration()

get_duration(string  $lock_type) : int

Get the amount of time to set for a given lock. 60 seconds by default.

Parameters

string $lock_type

A string to identify different lock types.

Returns

int