Make JobQueueGroup::push() update the queuesHaveJobs() cache
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 11 Sep 2016 11:57:12 +0000 (04:57 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sun, 11 Sep 2016 11:57:12 +0000 (04:57 -0700)
This makes it so jobs can run sooner with $wgJobRunRate

Bug: T145206
Change-Id: Ia7673f51312f90a696fa056bd3daf7f3f440782b

includes/jobqueue/JobQueueGroup.php

index 8d57562..de5f410 100644 (file)
@@ -142,6 +142,20 @@ class JobQueueGroup {
                                $this->cache->clear( 'queues-ready' );
                        }
                }
+
+               $cache = ObjectCache::getLocalClusterInstance();
+               $cache->set(
+                       $cache->makeGlobalKey( 'jobqueue', $this->wiki, 'hasjobs', self::TYPE_ANY ),
+                       'true',
+                       15
+               );
+               if ( array_intersect( array_keys( $jobsByType ), $this->getDefaultQueueTypes() ) ) {
+                       $cache->set(
+                               $cache->makeGlobalKey( 'jobqueue', $this->wiki, 'hasjobs', self::TYPE_DEFAULT ),
+                               'true',
+                               15
+                       );
+               }
        }
 
        /**
@@ -298,8 +312,8 @@ class JobQueueGroup {
         * @since 1.23
         */
        public function queuesHaveJobs( $type = self::TYPE_ANY ) {
-               $key = wfMemcKey( 'jobqueue', 'queueshavejobs', $type );
                $cache = ObjectCache::getLocalClusterInstance();
+               $key = $cache->makeGlobalKey( 'jobqueue', $this->wiki, 'hasjobs', $type );
 
                $value = $cache->get( $key );
                if ( $value === false ) {