49 $unclaimed =& $this->getQueueData(
'unclaimed', [] );
51 foreach ( $jobs as
$job ) {
52 if (
$job->ignoreDuplicates() ) {
53 $sha1 = sha1( serialize(
$job->getDeduplicationInfo() ) );
54 if ( !isset( $unclaimed[$sha1] ) ) {
55 $unclaimed[$sha1] =
$job;
69 return [
'random',
'timestamp',
'fifo' ];
96 $unclaimed = $this->getQueueData(
'unclaimed' );
98 return $unclaimed ? count( $unclaimed ) : 0;
107 $claimed = $this->getQueueData(
'claimed' );
109 return $claimed ? count( $claimed ) : 0;
122 $unclaimed =& $this->getQueueData(
'unclaimed' );
123 $claimed =& $this->getQueueData(
'claimed', [] );
125 if ( $this->order ===
'random' ) {
126 $key = array_rand( $unclaimed );
128 $key = array_key_first( $unclaimed );
131 $spec = $unclaimed[$key];
132 unset( $unclaimed[$key] );
137 $job->setMetadata(
'claimId', array_key_last( $claimed ) );
152 $claimed =& $this->getQueueData(
'claimed' );
153 unset( $claimed[
$job->getMetadata(
'claimId' )] );
160 if ( isset( self::$data[$this->type][$this->domain] ) ) {
161 unset( self::$data[$this->type][$this->domain] );
162 if ( !self::$data[$this->type] ) {
163 unset( self::$data[$this->type] );
174 $unclaimed = $this->getQueueData(
'unclaimed' );
176 return new ArrayIterator( [] );
181 function ( $value ) {
193 $claimed = $this->getQueueData(
'claimed' );
195 return new ArrayIterator( [] );
200 function ( $value ) {
220 private function &getQueueData( $field, $init =
null ) {
221 if ( !isset( self::$data[$this->type][$this->domain][$field] ) ) {
222 if ( $init !==
null ) {
array $params
The job parameters.
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.
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