Pheanstalk
in package
implements
PheanstalkInterface
Pheanstalk is a PHP client for the beanstalkd workqueue.
The Pheanstalk class is a simple facade for the various underlying components.
Tags
Interfaces, Classes and Traits
Table of Contents
- VERSION = '3.2.1'
- $_connection : mixed
- $_using : mixed
- $_watching : mixed
- __construct() : mixed
- bury() : mixed
- Puts a job into a 'buried' state, revived only by 'kick' command.
- delete() : $this
- Permanently deletes a job.
- getConnection() : Connection
- The internal connection object.
- ignore() : $this
- Remove the specified tube from the watchlist.
- kick() : int
- Kicks buried or delayed jobs into a 'ready' state.
- kickJob() : $this
- A variant of kick that operates with a single job. If the given job exists and is in a buried or delayed state, it will be moved to the ready queue of the the same tube where it currently belongs.
- listTubes() : array<string|int, mixed>
- The names of all tubes on the server.
- listTubesWatched() : array<string|int, mixed>
- The names of the tubes being watched, to reserve jobs from.
- listTubeUsed() : string
- The name of the current tube used for publishing jobs to.
- pauseTube() : $this
- Temporarily prevent jobs being reserved from the given tube.
- peek() : object
- Inspect a job in the system, regardless of what tube it is in.
- peekBuried() : object
- Inspect the next job in the list of buried jobs of the specified tube.
- peekDelayed() : object
- Inspect the shortest-remaining-delayed job in the specified tube. If no tube is specified, the currently used tube in used.
- peekReady() : object
- Inspect the next ready job in the specified tube. If no tube is specified, the currently used tube in used.
- put() : int
- Puts a job on the queue.
- putInTube() : int
- Puts a job on the queue using specified tube.
- release() : $this
- Puts a reserved job back into the ready queue.
- reserve() : object
- Reserves/locks a ready job in a watched tube.
- reserveFromTube() : object
- Reserves/locks a ready job from the specified tube.
- resumeTube() : $this
- Resume jobs for a given paused tube.
- setConnection() : $this
- stats() : object
- Gives statistical information about the beanstalkd system as a whole.
- statsJob() : object
- Gives statistical information about the specified job if it exists.
- statsTube() : object
- Gives statistical information about the specified tube if it exists.
- touch() : $this
- Allows a worker to request more time to work on a job.
- useTube() : $this
- Change to the specified tube name for publishing jobs to.
- watch() : $this
- Add the specified tube to the watchlist, to reserve jobs from.
- watchOnly() : $this
- Adds the specified tube to the watchlist, to reserve jobs from, and ignores any other tubes remaining on the watchlist.
- _dispatch() : Response
- Dispatches the specified command to the connection object.
- _reconnect() : mixed
- Creates a new connection object, based on the existing connection object, and re-establishes the used tube and watchlist.
Constants
VERSION
public
mixed
VERSION
= '3.2.1'
Properties
$_connection
private
mixed
$_connection
$_using
private
mixed
$_using
= PheanstalkPheanstalkInterface::DEFAULT_TUBE
$_watching
private
mixed
$_watching
= array(PheanstalkPheanstalkInterface::DEFAULT_TUBE => true)
Methods
__construct()
public
__construct(string $host[, int $port = PheanstalkInterface::DEFAULT_PORT ][, int $connectTimeout = null ][, bool $connectPersistent = false ]) : mixed
Parameters
- $host : string
- $port : int = PheanstalkInterface::DEFAULT_PORT
- $connectTimeout : int = null
- $connectPersistent : bool = false
Return values
mixed —bury()
Puts a job into a 'buried' state, revived only by 'kick' command.
public
bury(mixed $job[, mixed $priority = PheanstalkInterface::DEFAULT_PRIORITY ]) : mixed
Parameters
- $job : mixed
- $priority : mixed = PheanstalkInterface::DEFAULT_PRIORITY
Return values
mixed —delete()
Permanently deletes a job.
public
delete(mixed $job) : $this
Parameters
- $job : mixed
-
Job
Return values
$this —getConnection()
The internal connection object.
public
getConnection() : Connection
Return values
Connection —ignore()
Remove the specified tube from the watchlist.
public
ignore(mixed $tube) : $this
Parameters
- $tube : mixed
Return values
$this —kick()
Kicks buried or delayed jobs into a 'ready' state.
public
kick(mixed $max) : int
Parameters
- $max : mixed
-
The maximum jobs to kick
Return values
int —Number of jobs kicked
kickJob()
A variant of kick that operates with a single job. If the given job exists and is in a buried or delayed state, it will be moved to the ready queue of the the same tube where it currently belongs.
public
kickJob(mixed $job) : $this
Parameters
- $job : mixed
-
Job
Return values
$this —listTubes()
The names of all tubes on the server.
public
listTubes() : array<string|int, mixed>
Return values
array<string|int, mixed> —listTubesWatched()
The names of the tubes being watched, to reserve jobs from.
public
listTubesWatched([mixed $askServer = false ]) : array<string|int, mixed>
Parameters
- $askServer : mixed = false
Return values
array<string|int, mixed> —listTubeUsed()
The name of the current tube used for publishing jobs to.
public
listTubeUsed([mixed $askServer = false ]) : string
Parameters
- $askServer : mixed = false
Return values
string —pauseTube()
Temporarily prevent jobs being reserved from the given tube.
public
pauseTube(mixed $tube, mixed $delay) : $this
Parameters
- $tube : mixed
-
The tube to pause
- $delay : mixed
-
Seconds before jobs may be reserved from this queue.
Return values
$this —peek()
Inspect a job in the system, regardless of what tube it is in.
public
peek(mixed $jobId) : object
Parameters
- $jobId : mixed
Return values
object —Job
peekBuried()
Inspect the next job in the list of buried jobs of the specified tube.
public
peekBuried([mixed $tube = null ]) : object
Parameters
- $tube : mixed = null
Return values
object —Job
peekDelayed()
Inspect the shortest-remaining-delayed job in the specified tube. If no tube is specified, the currently used tube in used.
public
peekDelayed([mixed $tube = null ]) : object
Parameters
- $tube : mixed = null
Return values
object —Job
peekReady()
Inspect the next ready job in the specified tube. If no tube is specified, the currently used tube in used.
public
peekReady([mixed $tube = null ]) : object
Parameters
- $tube : mixed = null
Return values
object —Job
put()
Puts a job on the queue.
public
put(mixed $data[, mixed $priority = PheanstalkInterface::DEFAULT_PRIORITY ][, mixed $delay = PheanstalkInterface::DEFAULT_DELAY ][, mixed $ttr = PheanstalkInterface::DEFAULT_TTR ]) : int
Parameters
- $data : mixed
-
The job data
- $priority : mixed = PheanstalkInterface::DEFAULT_PRIORITY
-
From 0 (most urgent) to 0xFFFFFFFF (least urgent)
- $delay : mixed = PheanstalkInterface::DEFAULT_DELAY
-
Seconds to wait before job becomes ready
- $ttr : mixed = PheanstalkInterface::DEFAULT_TTR
-
Time To Run: seconds a job can be reserved for
Return values
int —The new job ID
putInTube()
Puts a job on the queue using specified tube.
public
putInTube(mixed $tube, mixed $data[, mixed $priority = PheanstalkInterface::DEFAULT_PRIORITY ][, mixed $delay = PheanstalkInterface::DEFAULT_DELAY ][, mixed $ttr = PheanstalkInterface::DEFAULT_TTR ]) : int
Parameters
- $tube : mixed
-
The tube to use
- $data : mixed
-
The job data
- $priority : mixed = PheanstalkInterface::DEFAULT_PRIORITY
-
From 0 (most urgent) to 0xFFFFFFFF (least urgent)
- $delay : mixed = PheanstalkInterface::DEFAULT_DELAY
-
Seconds to wait before job becomes ready
- $ttr : mixed = PheanstalkInterface::DEFAULT_TTR
-
Time To Run: seconds a job can be reserved for
Return values
int —The new job ID
release()
Puts a reserved job back into the ready queue.
public
release(mixed $job[, mixed $priority = PheanstalkInterface::DEFAULT_PRIORITY ][, mixed $delay = PheanstalkInterface::DEFAULT_DELAY ]) : $this
Parameters
- $job : mixed
-
Job
- $priority : mixed = PheanstalkInterface::DEFAULT_PRIORITY
-
From 0 (most urgent) to 0xFFFFFFFF (least urgent)
- $delay : mixed = PheanstalkInterface::DEFAULT_DELAY
-
Seconds to wait before job becomes ready
Return values
$this —reserve()
Reserves/locks a ready job in a watched tube.
public
reserve([mixed $timeout = null ]) : object
Parameters
- $timeout : mixed = null
Return values
object —Job
reserveFromTube()
Reserves/locks a ready job from the specified tube.
public
reserveFromTube(mixed $tube[, mixed $timeout = null ]) : object
Parameters
- $tube : mixed
- $timeout : mixed = null
Return values
object —Job
resumeTube()
Resume jobs for a given paused tube.
public
resumeTube(mixed $tube) : $this
Parameters
- $tube : mixed
-
The tube to resume
Return values
$this —setConnection()
public
setConnection(Connection $connection) : $this
Parameters
- $connection : Connection
Return values
$this —stats()
Gives statistical information about the beanstalkd system as a whole.
public
stats() : object
Return values
object —statsJob()
Gives statistical information about the specified job if it exists.
public
statsJob(mixed $job) : object
Parameters
- $job : mixed
Return values
object —statsTube()
Gives statistical information about the specified tube if it exists.
public
statsTube(mixed $tube) : object
Parameters
- $tube : mixed
Return values
object —touch()
Allows a worker to request more time to work on a job.
public
touch(mixed $job) : $this
Parameters
- $job : mixed
Return values
$this —useTube()
Change to the specified tube name for publishing jobs to.
public
useTube(mixed $tube) : $this
Parameters
- $tube : mixed
Return values
$this —watch()
Add the specified tube to the watchlist, to reserve jobs from.
public
watch(mixed $tube) : $this
Parameters
- $tube : mixed
Return values
$this —watchOnly()
Adds the specified tube to the watchlist, to reserve jobs from, and ignores any other tubes remaining on the watchlist.
public
watchOnly(mixed $tube) : $this
Parameters
- $tube : mixed
Return values
$this —_dispatch()
Dispatches the specified command to the connection object.
private
_dispatch(Command $command) : Response
If a SocketException occurs, the connection is reset, and the command is re-attempted once.
Parameters
- $command : Command
Return values
Response —_reconnect()
Creates a new connection object, based on the existing connection object, and re-establishes the used tube and watchlist.
private
_reconnect() : mixed