protected function getConnection() {
$conn = $this->redisPool->getConnection( $this->server );
if ( !$conn ) {
- throw new JobQueueConnectionError( "Unable to connect to redis server." );
+ throw new JobQueueConnectionError(
+ "Unable to connect to redis server {$this->server}." );
}
return $conn;
*/
private function getGlobalKey( $name ) {
$parts = array( 'global', 'jobqueue', $name );
- if ( strlen( $this->key ) ) { // namespaced queue (for testing)
- $parts[] = $this->key;
- }
-
foreach ( $parts as $part ) {
if ( !preg_match( '/[a-zA-Z0-9_-]+/', $part ) ) {
throw new InvalidArgumentException( "Key part characters are out of range." );
/**
* @param string $prop
- * @param string|null $type
+ * @param string|null $type Override this for sibling queues
* @return string
*/
private function getQueueKey( $prop, $type = null ) {
$type = is_string( $type ) ? $type : $this->type;
list( $db, $prefix ) = wfSplitWikiID( $this->wiki );
- if ( strlen( $this->key ) ) { // namespaced queue (for testing)
- return wfForeignMemcKey( $db, $prefix, 'jobqueue', $type, $this->key, $prop );
- } else {
- return wfForeignMemcKey( $db, $prefix, 'jobqueue', $type, $prop );
- }
- }
+ $keyspace = $prefix ? "$db-$prefix" : $db;
- /**
- * @param string $key
- * @return void
- */
- public function setTestingPrefix( $key ) {
- $this->key = $key;
+ $parts = array( $keyspace, 'jobqueue', $type, $prop );
+
+ // Parts are typically ASCII, but encode for sanity to escape ":"
+ return implode( ':', array_map( 'rawurlencode', $parts ) );
}
}