Merge "ResourceLoaderStartUpModule: Use hashMtime to detect config changes"
[lhc/web/wiklou.git] / includes / objectcache / MemcachedPeclBagOStuff.php
index 9f06fa0..18546d4 100644 (file)
@@ -37,6 +37,8 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
         *   - compress_threshold:  The minimum size an object must be before it is compressed
         *   - timeout:             The read timeout in microseconds
         *   - connect_timeout:     The connect timeout in seconds
+        *   - retry_timeout:       Time in seconds to wait before retrying a failed connect attempt
+        *   - server_failure_limit:  Limit for server connect failures before it is removed
         *   - serializer:          May be either "php" or "igbinary". Igbinary produces more compact
         *                          values, but serialization is much slower unless the php.ini option
         *                          igbinary.compact_strings is off.
@@ -47,7 +49,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
                if ( $params['persistent'] ) {
                        // The pool ID must be unique to the server/option combination.
                        // The Memcached object is essentially shared for each pool ID.
-                       // We can only resuse a pool ID if we keep the config consistent.
+                       // We can only reuse a pool ID if we keep the config consistent.
                        $this->client = new Memcached( md5( serialize( $params ) ) );
                        if ( count( $this->client->getServerList() ) ) {
                                wfDebug( __METHOD__ . ": persistent Memcached object already loaded.\n" );
@@ -61,6 +63,14 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
                        $params['serializer'] = 'php';
                }
 
+               if ( isset( $params['retry_timeout'] ) ) {
+                       $this->client->setOption( Memcached::OPT_RETRY_TIMEOUT, $params['retry_timeout'] );
+               }
+
+               if ( isset( $params['server_failure_limit'] ) ) {
+                       $this->client->setOption( Memcached::OPT_SERVER_FAILURE_LIMIT, $params['server_failure_limit'] );
+               }
+
                // The compression threshold is an undocumented php.ini option for some
                // reason. There's probably not much harm in setting it globally, for
                // compatibility with the settings for the PHP client.
@@ -87,13 +97,13 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
                                break;
                        case 'igbinary':
                                if ( !Memcached::HAVE_IGBINARY ) {
-                                       throw new MWException( __CLASS__.': the igbinary extension is not available ' .
+                                       throw new MWException( __CLASS__ . ': the igbinary extension is not available ' .
                                                'but igbinary serialization was requested.' );
                                }
                                $this->client->setOption( Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_IGBINARY );
                                break;
                        default:
-                               throw new MWException( __CLASS__.': invalid value for serializer parameter' );
+                               throw new MWException( __CLASS__ . ': invalid value for serializer parameter' );
                }
                $servers = array();
                foreach ( $params['servers'] as $host ) {
@@ -166,17 +176,6 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
                return $this->checkResult( $key, parent::add( $key, $value, $exptime ) );
        }
 
-       /**
-        * @param $key string
-        * @param $value int
-        * @param $exptime
-        * @return Mixed
-        */
-       public function replace( $key, $value, $exptime = 0 ) {
-               $this->debugLog( "replace($key)" );
-               return $this->checkResult( $key, parent::replace( $key, $value, $exptime ) );
-       }
-
        /**
         * @param $key string
         * @param $value int
@@ -206,7 +205,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
         * the client, but some day we might find a case where it should be
         * different.
         *
-        * @param $key string The key used by the caller, or false if there wasn't one.
+        * @param string $key The key used by the caller, or false if there wasn't one.
         * @param $result Mixed The return value
         * @return Mixed
         */