diff options
Diffstat (limited to 'includes/objectcache/MemcachedPeclBagOStuff.php')
-rw-r--r-- | includes/objectcache/MemcachedPeclBagOStuff.php | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/includes/objectcache/MemcachedPeclBagOStuff.php b/includes/objectcache/MemcachedPeclBagOStuff.php index c853bcf4..f2c49281 100644 --- a/includes/objectcache/MemcachedPeclBagOStuff.php +++ b/includes/objectcache/MemcachedPeclBagOStuff.php @@ -43,8 +43,10 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { * values, but serialization is much slower unless the php.ini option * igbinary.compact_strings is off. * @param array $params + * @throws MWException */ function __construct( $params ) { + parent::__construct( $params ); $params = $this->applyDefaultParams( $params ); if ( $params['persistent'] ) { @@ -53,7 +55,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { // 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" ); + $this->logger->debug( __METHOD__ . ": persistent Memcached object already loaded." ); return; // already initialized; don't add duplicate servers } } else { @@ -119,11 +121,9 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { * @return mixed */ public function get( $key, &$casToken = null ) { - wfProfileIn( __METHOD__ ); $this->debugLog( "get($key)" ); $result = $this->client->get( $this->encodeKey( $key ), null, $casToken ); $result = $this->checkResult( $key, $result ); - wfProfileOut( __METHOD__ ); return $result; } @@ -145,19 +145,18 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { * @param int $exptime * @return bool */ - public function cas( $casToken, $key, $value, $exptime = 0 ) { + protected function cas( $casToken, $key, $value, $exptime = 0 ) { $this->debugLog( "cas($key)" ); return $this->checkResult( $key, parent::cas( $casToken, $key, $value, $exptime ) ); } /** * @param string $key - * @param int $time * @return bool */ - public function delete( $key, $time = 0 ) { + public function delete( $key ) { $this->debugLog( "delete($key)" ); - $result = parent::delete( $key, $time ); + $result = parent::delete( $key ); if ( $result === false && $this->client->getResultCode() === Memcached::RES_NOTFOUND ) { // "Not found" is counted as success in our interface return true; @@ -224,14 +223,16 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { break; default: $msg = $this->client->getResultMessage(); + $logCtx = array(); if ( $key !== false ) { $server = $this->client->getServerByKey( $key ); - $serverName = "{$server['host']}:{$server['port']}"; - $msg = "Memcached error for key \"$key\" on server \"$serverName\": $msg"; + $logCtx['memcached-server'] = "{$server['host']}:{$server['port']}"; + $logCtx['memcached-key'] = $key; + $msg = "Memcached error for key \"{memcached-key}\" on server \"{memcached-server}\": $msg"; } else { $msg = "Memcached error: $msg"; } - wfDebugLog( 'memcached-serious', $msg ); + $this->logger->error( $msg, $logCtx ); $this->setLastError( BagOStuff::ERR_UNEXPECTED ); } return $result; @@ -242,11 +243,9 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { * @return array */ public function getMulti( array $keys ) { - wfProfileIn( __METHOD__ ); $this->debugLog( 'getMulti(' . implode( ', ', $keys ) . ')' ); $callback = array( $this, 'encodeKey' ); $result = $this->client->getMulti( array_map( $callback, $keys ) ); - wfProfileOut( __METHOD__ ); $result = $result ?: array(); // must be an array return $this->checkResult( false, $result ); } @@ -257,7 +256,6 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { * @return bool */ public function setMulti( array $data, $exptime = 0 ) { - wfProfileIn( __METHOD__ ); foreach ( $data as $key => $value ) { $encKey = $this->encodeKey( $key ); if ( $encKey !== $key ) { @@ -267,7 +265,6 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { } $this->debugLog( 'setMulti(' . implode( ', ', array_keys( $data ) ) . ')' ); $result = $this->client->setMulti( $data, $this->fixExpiry( $exptime ) ); - wfProfileOut( __METHOD__ ); return $this->checkResult( false, $result ); } } |