Merge "Do not block autopromote on partial blocks"
[lhc/web/wiklou.git] / includes / libs / objectcache / MemcachedBagOStuff.php
index 3d6bd16..9f1c98a 100644 (file)
  *
  * @ingroup Cache
  */
-class MemcachedBagOStuff extends BagOStuff {
-       /** @var MemcachedClient|Memcached */
-       protected $client;
-
+abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
        function __construct( array $params ) {
                parent::__construct( $params );
 
                $this->attrMap[self::ATTR_SYNCWRITES] = self::QOS_SYNCWRITES_BE; // unreliable
-       }
-
-       /**
-        * Fill in some defaults for missing keys in $params.
-        *
-        * @param array $params
-        * @return array
-        */
-       protected function applyDefaultParams( $params ) {
-               return $params + [
-                       'compress_threshold' => 1500,
-                       'connect_timeout' => 0.5,
-                       'debug' => false
-               ];
-       }
-
-       protected function doGet( $key, $flags = 0, &$casToken = null ) {
-               return $this->client->get( $this->validateKeyEncoding( $key ), $casToken );
-       }
-
-       public function set( $key, $value, $exptime = 0, $flags = 0 ) {
-               return $this->client->set( $this->validateKeyEncoding( $key ), $value,
-                       $this->fixExpiry( $exptime ) );
-       }
-
-       protected function cas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
-               return $this->client->cas( $casToken, $this->validateKeyEncoding( $key ),
-                       $value, $this->fixExpiry( $exptime ) );
-       }
-
-       public function delete( $key, $flags = 0 ) {
-               return $this->client->delete( $this->validateKeyEncoding( $key ) );
-       }
-
-       public function add( $key, $value, $exptime = 0, $flags = 0 ) {
-               return $this->client->add( $this->validateKeyEncoding( $key ), $value,
-                       $this->fixExpiry( $exptime ) );
-       }
-
-       public function incr( $key, $value = 1 ) {
-               $n = $this->client->incr( $this->validateKeyEncoding( $key ), $value );
-
-               return ( $n !== false && $n !== null ) ? $n : false;
-       }
-
-       public function decr( $key, $value = 1 ) {
-               $n = $this->client->decr( $this->validateKeyEncoding( $key ), $value );
-
-               return ( $n !== false && $n !== null ) ? $n : false;
-       }
-
-       public function changeTTL( $key, $exptime = 0, $flags = 0 ) {
-               return $this->client->touch( $this->validateKeyEncoding( $key ),
-                       $this->fixExpiry( $exptime ) );
-       }
-
-       /**
-        * Get the underlying client object. This is provided for debugging
-        * purposes.
-        * @return MemcachedClient|Memcached
-        */
-       public function getClient() {
-               return $this->client;
+               $this->segmentationSize = $params['maxPreferedKeySize'] ?? 917504; // < 1MiB
        }
 
        /**