38 parent::__construct( $params );
48 $unclaimed =& $this->getQueueData(
'unclaimed', [] );
50 foreach ( $jobs as
$job ) {
51 if (
$job->ignoreDuplicates() ) {
52 $sha1 = sha1( serialize(
$job->getDeduplicationInfo() ) );
53 if ( !isset( $unclaimed[$sha1] ) ) {
54 $unclaimed[$sha1] =
$job;
68 return [
'random',
'timestamp',
'fifo' ];
95 $unclaimed = $this->getQueueData(
'unclaimed' );
97 return $unclaimed ? count( $unclaimed ) : 0;
106 $claimed = $this->getQueueData(
'claimed' );
108 return $claimed ? count( $claimed ) : 0;
121 $unclaimed =& $this->getQueueData(
'unclaimed' );
122 $claimed =& $this->getQueueData(
'claimed', [] );
124 if ( $this->order ===
'random' ) {
125 $key = array_rand( $unclaimed );
127 $key = array_key_first( $unclaimed );
130 $spec = $unclaimed[$key];
131 unset( $unclaimed[$key] );
136 $job->setMetadata(
'claimId', array_key_last( $claimed ) );
151 $claimed =& $this->getQueueData(
'claimed' );
152 unset( $claimed[
$job->getMetadata(
'claimId' )] );
159 if ( isset( self::$data[$this->type][$this->domain] ) ) {
160 unset( self::$data[$this->type][$this->domain] );
161 if ( !self::$data[$this->type] ) {
162 unset( self::$data[$this->type] );
173 $unclaimed = $this->getQueueData(
'unclaimed' );
175 return new ArrayIterator( [] );
180 function ( $value ) {
192 $claimed = $this->getQueueData(
'claimed' );
194 return new ArrayIterator( [] );
199 function ( $value ) {
219 private function &getQueueData( $field, $init =
null ) {
220 if ( !isset( self::$data[$this->type][$this->domain][$field] ) ) {
221 if ( $init !==
null ) {
Simple store for keeping values in an associative array for the current process.
Class to handle job queues stored in PHP memory for testing.
doDelete()
to override JobQueue::delete()
__construct(array $params)
doBatchPush(array $jobs, $flags)
jobFromSpecInternal(IJobSpecification $spec)
Class to handle enqueueing and running of background jobs.
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