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;
}
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 );
- return $this->client->decr( $key, $value );
+ return $this->client->decr( $key, $value ) ?? false;
}
}
// merge on non-existing value
$merged = $this->cache->merge( $key, $callback, 5 );
$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, 5 );
$this->assertTrue( $merged );
- $this->assertEquals( $this->cache->get( $key ), 'mergedmerged' );
+ $this->assertEquals( 'mergedmerged', $this->cache->get( $key ) );
}
/**