The get() $cas_token parameter was changed into $flags, which can act
as a switch to make the return value an associative array of details.
pecl and PHP-based memcached BagOStuff class both pass all tests now.
Bug: T196125
Change-Id: I4678250331a48db4d50d1fc6c489c991a4dee920
wikitext table captions, wikitext table headings, wikitext table cells. HTML
headings, HTML list items, HTML table captions, HTML table headings, HTML
table cells will not have this trimming behavior.
wikitext table captions, wikitext table headings, wikitext table cells. HTML
headings, HTML list items, HTML table captions, HTML table headings, HTML
table cells will not have this trimming behavior.
+* (T196125) php-memcached 3.0 (provided with PHP 7.0) is now supported.
== Compatibility ==
MediaWiki 1.31 requires PHP 7.0.0 or later. Although HHVM 3.18.5 or later is
== Compatibility ==
MediaWiki 1.31 requires PHP 7.0.0 or later. Although HHVM 3.18.5 or later is
protected function getWithToken( $key, &$casToken, $flags = 0 ) {
$this->debugLog( "get($key)" );
protected function getWithToken( $key, &$casToken, $flags = 0 ) {
$this->debugLog( "get($key)" );
- $result = $this->client->get( $this->validateKeyEncoding( $key ), null, $casToken );
+ if ( defined( Memcached::class . '::GET_EXTENDED' ) ) { // v3.0.0
+ $flags = Memcached::GET_EXTENDED;
+ $res = $this->client->get( $this->validateKeyEncoding( $key ), null, $flags );
+ if ( is_array( $res ) ) {
+ $result = $res['value'];
+ $casToken = $res['cas'];
+ } else {
+ $result = false;
+ $casToken = null;
+ }
+ } else {
+ $result = $this->client->get( $this->validateKeyEncoding( $key ), null, $casToken );
+ }
$result = $this->checkResult( $key, $result );
return $result;
}
$result = $this->checkResult( $key, $result );
return $result;
}
public function incr( $key, $value = 1 ) {
$this->validateKeyEncoding( $key );
public function incr( $key, $value = 1 ) {
$this->validateKeyEncoding( $key );
- return $this->client->incr( $key, $value );
+ return $this->client->incr( $key, $value ) ?? false;
}
public function decr( $key, $value = 1 ) {
$this->validateKeyEncoding( $key );
}
public function decr( $key, $value = 1 ) {
$this->validateKeyEncoding( $key );
- return $this->client->decr( $key, $value );
+ return $this->client->decr( $key, $value ) ?? false;
// merge on non-existing value
$merged = $this->cache->merge( $key, $callback, 0 );
$this->assertTrue( $merged );
// merge on non-existing value
$merged = $this->cache->merge( $key, $callback, 0 );
$this->assertTrue( $merged );
- $this->assertEquals( $this->cache->get( $key ), 'merged' );
+ $this->assertEquals( 'merged', $this->cache->get( $key ) );
// merge on existing value
$merged = $this->cache->merge( $key, $callback, 0 );
$this->assertTrue( $merged );
// merge on existing value
$merged = $this->cache->merge( $key, $callback, 0 );
$this->assertTrue( $merged );
- $this->assertEquals( $this->cache->get( $key ), 'mergedmerged' );
+ $this->assertEquals( 'mergedmerged', $this->cache->get( $key ) );
/*
* Test concurrent merges by forking this process, if:
/*
* Test concurrent merges by forking this process, if: