[JobQueue] Make use of the isEmpty() function caching in pop().
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 31 Oct 2012 00:32:50 +0000 (17:32 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 31 Oct 2012 00:43:03 +0000 (17:43 -0700)
Change-Id: I92f538f4eb1e912f3446423a0ca51d9a63bf4457

includes/job/JobQueueDB.php

index f6003b2..d9465fb 100644 (file)
@@ -111,11 +111,14 @@ class JobQueueDB extends JobQueue {
        protected function doPop() {
                global $wgMemc;
 
-               $uuid = wfRandomString( 32 ); // pop attempt
+               if ( $wgMemc->get( $this->getEmptinessCacheKey() ) === 'true' ) {
+                       return false; // queue is empty
+               }
 
                $dbw = $this->getMasterDB();
                $dbw->commit( __METHOD__, 'flush' ); // flush existing transaction
 
+               $uuid = wfRandomString( 32 ); // pop attempt
                $job = false; // job popped off
                $autoTrx = $dbw->getFlag( DBO_TRX ); // automatic begin() enabled?
                $dbw->clearFlag( DBO_TRX ); // make each query its own transaction