46 $unclaimed =& $this->getQueueData(
'unclaimed', [] );
48 foreach ( $jobs as
$job ) {
49 if (
$job->ignoreDuplicates() ) {
50 $sha1 = sha1( serialize(
$job->getDeduplicationInfo() ) );
51 if ( !isset( $unclaimed[$sha1] ) ) {
52 $unclaimed[$sha1] =
$job;
66 return [
'random',
'timestamp',
'fifo' ];
93 $unclaimed = $this->getQueueData(
'unclaimed' );
95 return $unclaimed ? count( $unclaimed ) : 0;
104 $claimed = $this->getQueueData(
'claimed' );
106 return $claimed ? count( $claimed ) : 0;
119 $unclaimed =& $this->getQueueData(
'unclaimed' );
120 $claimed =& $this->getQueueData(
'claimed', [] );
122 if ( $this->order ===
'random' ) {
123 $key = array_rand( $unclaimed );
125 $key = array_key_first( $unclaimed );
128 $spec = $unclaimed[$key];
129 unset( $unclaimed[$key] );
134 $job->setMetadata(
'claimId', array_key_last( $claimed ) );
149 $claimed =& $this->getQueueData(
'claimed' );
150 unset( $claimed[
$job->getMetadata(
'claimId' )] );
157 if ( isset( self::$data[$this->type][$this->domain] ) ) {
158 unset( self::$data[$this->type][$this->domain] );
159 if ( !self::$data[$this->type] ) {
160 unset( self::$data[$this->type] );
171 $unclaimed = $this->getQueueData(
'unclaimed' );
173 return new ArrayIterator( [] );
178 function ( $value ) {
190 $claimed = $this->getQueueData(
'claimed' );
192 return new ArrayIterator( [] );
197 function ( $value ) {
217 private function &getQueueData( $field, $init =
null ) {
218 if ( !isset( self::$data[$this->type][$this->domain][$field] ) ) {
219 if ( $init !==
null ) {
array $params
The job parameters.
Simple store for keeping values in an associative array for the current process.
PHP memory-backed job queue storage, for testing.
doDelete()
to override JobQueue::delete()
__construct(array $params)
doBatchPush(array $jobs, $flags)
jobFromSpecInternal(IJobSpecification $spec)
Base class for queueing and running background jobs from a storage backend.
factoryJob( $command, $params)
getAcquiredCount()
Get the number of acquired jobs (these are temporarily out of the queue).
string $domain
DB domain ID.
Convenience class for generating iterators from iterators.
Multi-datacenter aware caching interface.
Interface for serializable objects that describe a job queue task.
Job that has a run() method and metadata accessors for JobQueue::pop() and JobQueue::ack().
if(count( $args)< 1) $job