/** @var RedisConnectionPool */
protected $redisPool;
- /** @var Array List of Redis server addresses */
+ /** @var array List of Redis server addresses */
protected $servers;
/**
}
try {
$conn->hDel( $this->getReadyQueueKey(), $this->encQueueName( $type, $wiki ) );
+
return true;
} catch ( RedisException $e ) {
$this->handleException( $conn, $e );
+
return false;
}
}
}
try {
$conn->hSet( $this->getReadyQueueKey(), $this->encQueueName( $type, $wiki ), time() );
+
return true;
} catch ( RedisException $e ) {
$this->handleException( $conn, $e );
+
return false;
}
}
}
} else { // cache miss
// Avoid duplicated effort
+ $rand = wfRandomString( 32 );
$conn->multi( Redis::MULTI );
- $conn->setnx( $this->getReadyQueueKey() . ":lock", 1 );
- $conn->expire( $this->getReadyQueueKey() . ":lock", 3600 );
+ $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
}
return $pendingDBs;
} catch ( RedisException $e ) {
$this->handleException( $conn, $e );
+
return array();
}
}
$conn->delete( $this->getReadyQueueKey() );
} catch ( RedisException $e ) {
$this->handleException( $conn, $e );
+
return false;
}
+
return true;
}
break;
}
}
+
return $conn;
}
*/
private function dencQueueName( $name ) {
list( $type, $wiki ) = explode( '/', $name, 2 );
+
return array( rawurldecode( $type ), rawurldecode( $wiki ) );
}
}