X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=blobdiff_plain;ds=sidebyside;f=includes%2Flibs%2Fobjectcache%2FRedisBagOStuff.php;h=743b9eba2c8146a8b9997b2acb1be857fc1a2b15;hb=24f03d327684bdd7ffc867934b56cc10973618d4;hp=f64fe7e780da484f4b7e184c0c1d2a09bff229ab;hpb=c7d3fcebc435e35389c0ae49bb37d7199e329ac1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/objectcache/RedisBagOStuff.php b/includes/libs/objectcache/RedisBagOStuff.php index f64fe7e780..743b9eba2c 100644 --- a/includes/libs/objectcache/RedisBagOStuff.php +++ b/includes/libs/objectcache/RedisBagOStuff.php @@ -86,13 +86,9 @@ class RedisBagOStuff extends BagOStuff { $this->attrMap[self::ATTR_SYNCWRITES] = self::QOS_SYNCWRITES_NONE; } - protected function doGet( $key, $flags = 0 ) { + protected function doGet( $key, $flags = 0, &$casToken = null ) { $casToken = null; - return $this->getWithToken( $key, $casToken, $flags ); - } - - protected function getWithToken( $key, &$casToken, $flags = 0 ) { list( $server, $conn ) = $this->getConnection( $key ); if ( !$conn ) { return false; @@ -110,7 +106,7 @@ class RedisBagOStuff extends BagOStuff { return $result; } - public function set( $key, $value, $expiry = 0, $flags = 0 ) { + protected function doSet( $key, $value, $expiry = 0, $flags = 0 ) { list( $server, $conn ) = $this->getConnection( $key ); if ( !$conn ) { return false; @@ -132,7 +128,7 @@ class RedisBagOStuff extends BagOStuff { return $result; } - public function delete( $key, $flags = 0 ) { + protected function doDelete( $key, $flags = 0 ) { list( $server, $conn ) = $this->getConnection( $key ); if ( !$conn ) { return false; @@ -150,7 +146,7 @@ class RedisBagOStuff extends BagOStuff { return $result; } - public function getMulti( array $keys, $flags = 0 ) { + public function doGetMulti( array $keys, $flags = 0 ) { $batches = []; $conns = []; foreach ( $keys as $key ) { @@ -297,10 +293,6 @@ class RedisBagOStuff extends BagOStuff { return $result; } - public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) { - return $this->mergeViaCas( $key, $callback, $exptime, $attempts ); - } - /** * Non-atomic implementation of incr(). * @@ -333,43 +325,32 @@ class RedisBagOStuff extends BagOStuff { return $result; } - public function changeTTL( $key, $expiry = 0, $flags = 0 ) { + public function changeTTL( $key, $exptime = 0, $flags = 0 ) { list( $server, $conn ) = $this->getConnection( $key ); if ( !$conn ) { return false; } - $expiry = $this->convertToRelative( $expiry ); + $relative = $this->expiryIsRelative( $exptime ); try { - $result = $conn->expire( $key, $expiry ); + if ( $exptime == 0 ) { + $result = $conn->persist( $key ); + $this->logRequest( 'persist', $key, $server, $result ); + } elseif ( $relative ) { + $result = $conn->expire( $key, $this->convertToRelative( $exptime ) ); + $this->logRequest( 'expire', $key, $server, $result ); + } else { + $result = $conn->expireAt( $key, $this->convertToExpiry( $exptime ) ); + $this->logRequest( 'expireAt', $key, $server, $result ); + } } catch ( RedisException $e ) { $result = false; $this->handleException( $conn, $e ); } - $this->logRequest( 'expire', $key, $server, $result ); return $result; } - /** - * @param mixed $data - * @return string - */ - protected function serialize( $data ) { - // Serialize anything but integers so INCR/DECR work - // Do not store integer-like strings as integers to avoid type confusion (T62563) - return is_int( $data ) ? $data : serialize( $data ); - } - - /** - * @param string $data - * @return mixed - */ - protected function unserialize( $data ) { - $int = intval( $data ); - return $data === (string)$int ? $int : unserialize( $data ); - } - /** * Get a Redis object with a connection suitable for fetching the specified key * @param string $key @@ -446,7 +427,7 @@ class RedisBagOStuff extends BagOStuff { * not. The safest response for us is to explicitly destroy the connection * object and let it be reopened during the next request. * @param RedisConnRef $conn - * @param Exception $e + * @param RedisException $e */ protected function handleException( RedisConnRef $conn, $e ) { $this->setLastError( BagOStuff::ERR_UNEXPECTED );