- // Avoid duplicated effort
- $rand = wfRandomString( 32 );
- $conn->multi( Redis::MULTI );
- $conn->setex( "{$rand}:lock", 3600, 1 );
- $conn->renamenx( "{$rand}:lock", $this->getReadyQueueKey() . ":lock" );
- if ( $conn->exec() !== array( true, true ) ) { // lock
- $conn->delete( "{$rand}:lock" );
- return array(); // already in progress
- }
-
- $pendingDBs = $this->findPendingWikiQueues(); // (type => list of wikis)
-
- $conn->multi( Redis::PIPELINE );
- $now = time();
- $map = array( '_epoch' => time() ); // dummy key for empty Redis collections
- foreach ( $pendingDBs as $type => $wikis ) {
- $conn->hSetNx( $this->getQueueTypesKey(), $type, 'enabled' );
- foreach ( $wikis as $wiki ) {
- $map[$this->encQueueName( $type, $wiki )] = $now;
- }
- }
- $conn->hMSet( $this->getReadyQueueKey(), $map );
- $conn->exec();
-
- $conn->delete( $this->getReadyQueueKey() . ":lock" ); // unlock