Aaron Schulz has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/349722 )
Change subject: Set a persistent connection ID for RedisConnectionPool
......................................................................
Set a persistent connection ID for RedisConnectionPool
This re-uses the options hash as the ID so that re-used connections
do not clobber each others settings.
Change-Id: I17e5993ecdab1770259803e06956b85b9ebb2ba6
---
M includes/libs/redis/RedisConnectionPool.php
1 file changed, 7 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/22/349722/1
diff --git a/includes/libs/redis/RedisConnectionPool.php
b/includes/libs/redis/RedisConnectionPool.php
index 7f43436..e3fc1a6 100644
--- a/includes/libs/redis/RedisConnectionPool.php
+++ b/includes/libs/redis/RedisConnectionPool.php
@@ -49,6 +49,8 @@
protected $persistent;
/** @var int Serializer to use (Redis::SERIALIZER_*) */
protected $serializer;
+ /** @var string ID for persistent connections */
+ protected $id;
/** @var int Current idle pool size */
protected $idlePoolSize = 0;
@@ -71,9 +73,10 @@
/**
* @param array $options
+ * @param string $id
* @throws Exception
*/
- protected function __construct( array $options ) {
+ protected function __construct( array $options, $id ) {
if ( !class_exists( 'Redis' ) ) {
throw new RuntimeException(
__CLASS__ . ' requires a Redis client library.
' .
@@ -95,6 +98,7 @@
} else {
throw new InvalidArgumentException( "Invalid serializer
specified." );
}
+ $this->id = $id;
}
/**
@@ -148,7 +152,7 @@
$id = sha1( serialize( $options ) );
// Initialize the object at the hash as needed...
if ( !isset( self::$instances[$id] ) ) {
- self::$instances[$id] = new self( $options );
+ self::$instances[$id] = new self( $options, $id );
}
return self::$instances[$id];
@@ -230,7 +234,7 @@
$conn = new Redis();
try {
if ( $this->persistent ) {
- $result = $conn->pconnect( $host, $port,
$this->connectTimeout );
+ $result = $conn->pconnect( $host, $port,
$this->connectTimeout, $this->id );
} else {
$result = $conn->connect( $host, $port,
$this->connectTimeout );
}
--
To view, visit https://gerrit.wikimedia.org/r/349722
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I17e5993ecdab1770259803e06956b85b9ebb2ba6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits