PheanstalkInterface
in
Table of Contents
- DEFAULT_DELAY = 0
- DEFAULT_PORT = 11300
- DEFAULT_PRIORITY = 1024
- DEFAULT_TTR = 60
- DEFAULT_TUBE = 'default'
- 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.
Constants
DEFAULT_DELAY
public
mixed
DEFAULT_DELAY
= 0
DEFAULT_PORT
public
mixed
DEFAULT_PORT
= 11300
DEFAULT_PRIORITY
public
mixed
DEFAULT_PRIORITY
= 1024
DEFAULT_TTR
public
mixed
DEFAULT_TTR
= 60
DEFAULT_TUBE
public
mixed
DEFAULT_TUBE
= 'default'
Methods
bury()
Puts a job into a 'buried' state, revived only by 'kick' command.
public
bury(Job $job[, int $priority = self::DEFAULT_PRIORITY ]) : mixed
Parameters
- $job : Job
- $priority : int = self::DEFAULT_PRIORITY
Return values
mixed —delete()
Permanently deletes a job.
public
delete(object $job) : $this
Parameters
- $job : object
-
Job
Return values
$this —getConnection()
The internal connection object.
public
getConnection() : Connection
Not required for general usage.
Return values
Connection —ignore()
Remove the specified tube from the watchlist.
public
ignore(string $tube) : $this
Does not execute an IGNORE command if the specified tube is not in the cached watchlist.
Parameters
- $tube : string
Return values
$this —kick()
Kicks buried or delayed jobs into a 'ready' state.
public
kick(int $max) : int
If there are buried jobs, it will kick up to $max of them. Otherwise, it will kick up to $max delayed jobs.
Parameters
- $max : int
-
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(Job $job) : $this
Parameters
- $job : Job
-
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([bool $askServer = false ]) : array<string|int, mixed>
Returns the cached watchlist if $askServer is false (the default), or queries the server for the watchlist if $askServer is true.
Parameters
- $askServer : bool = false
Return values
array<string|int, mixed> —listTubeUsed()
The name of the current tube used for publishing jobs to.
public
listTubeUsed([bool $askServer = false ]) : string
Returns the cached value if $askServer is false (the default), or queries the server for the currently used tube if $askServer is true.
Parameters
- $askServer : bool = false
Return values
string —pauseTube()
Temporarily prevent jobs being reserved from the given tube.
public
pauseTube(string $tube, int $delay) : $this
Parameters
- $tube : string
-
The tube to pause
- $delay : int
-
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(int $jobId) : object
Parameters
- $jobId : int
Return values
object —Job
peekBuried()
Inspect the next job in the list of buried jobs of the specified tube.
public
peekBuried([string $tube = null ]) : object
If no tube is specified, the currently used tube in used.
Parameters
- $tube : string = 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([string $tube = null ]) : object
Parameters
- $tube : string = 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([string $tube = null ]) : object
Parameters
- $tube : string = null
Return values
object —Job
put()
Puts a job on the queue.
public
put(string $data[, int $priority = self::DEFAULT_PRIORITY ][, int $delay = self::DEFAULT_DELAY ][, int $ttr = self::DEFAULT_TTR ]) : int
Parameters
- $data : string
-
The job data
- $priority : int = self::DEFAULT_PRIORITY
-
From 0 (most urgent) to 0xFFFFFFFF (least urgent)
- $delay : int = self::DEFAULT_DELAY
-
Seconds to wait before job becomes ready
- $ttr : int = self::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(string $tube, string $data[, int $priority = self::DEFAULT_PRIORITY ][, int $delay = self::DEFAULT_DELAY ][, int $ttr = self::DEFAULT_TTR ]) : int
Using this method is equivalent to calling useTube() then put(), with the added benefit that it will not execute the USE command if the client is already using the specified tube.
Parameters
- $tube : string
-
The tube to use
- $data : string
-
The job data
- $priority : int = self::DEFAULT_PRIORITY
-
From 0 (most urgent) to 0xFFFFFFFF (least urgent)
- $delay : int = self::DEFAULT_DELAY
-
Seconds to wait before job becomes ready
- $ttr : int = self::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(object $job[, int $priority = self::DEFAULT_PRIORITY ][, int $delay = self::DEFAULT_DELAY ]) : $this
Marks the jobs state as "ready" to be run by any client. It is normally used when the job fails because of a transitory error.
Parameters
- $job : object
-
Job
- $priority : int = self::DEFAULT_PRIORITY
-
From 0 (most urgent) to 0xFFFFFFFF (least urgent)
- $delay : int = self::DEFAULT_DELAY
-
Seconds to wait before job becomes ready
Return values
$this —reserve()
Reserves/locks a ready job in a watched tube.
public
reserve([int $timeout = null ]) : object
A non-null timeout uses the 'reserve-with-timeout' instead of 'reserve'.
A timeout value of 0 will cause the server to immediately return either a response or TIMED_OUT. A positive value of timeout will limit the amount of time the client will block on the reserve request until a job becomes available.
Parameters
- $timeout : int = null
Return values
object —Job
reserveFromTube()
Reserves/locks a ready job from the specified tube.
public
reserveFromTube(string $tube[, int $timeout = null ]) : object
A non-null timeout uses the 'reserve-with-timeout' instead of 'reserve'.
A timeout value of 0 will cause the server to immediately return either a response or TIMED_OUT. A positive value of timeout will limit the amount of time the client will block on the reserve request until a job becomes available.
Using this method is equivalent to calling watch(), ignore() then reserve(), with the added benefit that it will not execute uneccessary WATCH or IGNORE commands if the client is already watching the specified tube.
Parameters
- $tube : string
- $timeout : int = null
Return values
object —Job
resumeTube()
Resume jobs for a given paused tube.
public
resumeTube(string $tube) : $this
Parameters
- $tube : string
-
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(Job|int $job) : object
Parameters
- $job : Job|int
Return values
object —statsTube()
Gives statistical information about the specified tube if it exists.
public
statsTube(string $tube) : object
Parameters
- $tube : string
Return values
object —touch()
Allows a worker to request more time to work on a job.
public
touch(Job $job) : $this
This is useful for jobs that potentially take a long time, but you still want the benefits of a TTR pulling a job away from an unresponsive worker. A worker may periodically tell the server that it's still alive and processing a job (e.g. it may do this on DEADLINE_SOON).
Parameters
- $job : Job
Return values
$this —useTube()
Change to the specified tube name for publishing jobs to.
public
useTube(string $tube) : $this
This method would be called 'use' if it were not a PHP reserved word.
Does not execute a USE command if the client is already using the specified tube.
Parameters
- $tube : string
Return values
$this —watch()
Add the specified tube to the watchlist, to reserve jobs from.
public
watch(string $tube) : $this
Does not execute a WATCH command if the client is already watching the specified tube.
Parameters
- $tube : string
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(string $tube) : $this
Parameters
- $tube : string