RedisLock
extends Lock
in package
implements
Lock
Interfaces, Classes and Traits
Table of Contents
- $name : string
- The name of the lock.
- $redis : Connection
- The Redis factory implementation.
- $seconds : int
- The number of seconds the lock should be maintained.
- __construct() : void
- Create a new lock instance.
- acquire() : bool
- Attempt to acquire the lock.
- block() : bool
- Attempt to acquire the lock for the given number of seconds.
- get() : bool
- Attempt to acquire the lock.
- release() : void
- Release the lock.
- availableAt() : int
- Get the "available at" UNIX timestamp.
- currentTime() : int
- Get the current system time as a UNIX timestamp.
- parseDateInterval() : DateTimeInterface|int
- If the given value is an interval, convert it to a DateTime instance.
- secondsUntil() : int
- Get the number of seconds until the given DateTime.
Properties
$name
The name of the lock.
protected
string
$name
$redis
The Redis factory implementation.
protected
Connection
$redis
$seconds
The number of seconds the lock should be maintained.
protected
int
$seconds
Methods
__construct()
Create a new lock instance.
public
__construct(Connection $redis, string $name, int $seconds) : void
Parameters
- $redis : Connection
- $name : string
- $seconds : int
Return values
void —acquire()
Attempt to acquire the lock.
public
acquire() : bool
Return values
bool —block()
Attempt to acquire the lock for the given number of seconds.
public
block(int $seconds[, callable|null $callback = null ]) : bool
Parameters
- $seconds : int
- $callback : callable|null = null
Tags
Return values
bool —get()
Attempt to acquire the lock.
public
get([callable|null $callback = null ]) : bool
Parameters
- $callback : callable|null = null
Return values
bool —release()
Release the lock.
public
release() : void
Return values
void —availableAt()
Get the "available at" UNIX timestamp.
protected
availableAt(DateTimeInterface|DateInterval|int $delay) : int
Parameters
- $delay : DateTimeInterface|DateInterval|int
Return values
int —currentTime()
Get the current system time as a UNIX timestamp.
protected
currentTime() : int
Return values
int —parseDateInterval()
If the given value is an interval, convert it to a DateTime instance.
protected
parseDateInterval(DateTimeInterface|DateInterval|int $delay) : DateTimeInterface|int
Parameters
- $delay : DateTimeInterface|DateInterval|int
Return values
DateTimeInterface|int —secondsUntil()
Get the number of seconds until the given DateTime.
protected
secondsUntil(DateTimeInterface|DateInterval|int $delay) : int
Parameters
- $delay : DateTimeInterface|DateInterval|int