Merge "Improve docs for Title::getInternalURL/getCanonicalURL"
[lhc/web/wiklou.git] / includes / libs / objectcache / RedisBagOStuff.php
index f64fe7e..2c74d45 100644 (file)
@@ -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;
@@ -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,21 +325,29 @@ 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;
        }