public function getMulti( array $keys, $flags = 0 ) {
$this->debugLog( 'getMulti(' . implode( ', ', $keys ) . ')' );
$callback = array( $this, 'encodeKey' );
- $result = $this->client->getMulti( array_map( $callback, $keys ) );
- $result = $result ?: array(); // must be an array
+ $encodedResult = $this->client->getMulti( array_map( $callback, $keys ) );
+ $encodedResult = $encodedResult ?: array(); // must be an array
+ $result = array();
+ foreach ( $encodedResult as $key => $value ) {
+ $key = $this->decodeKey( $key );
+ $result[$key] = $value;
+ }
return $this->checkResult( false, $result );
}
public function getMulti( array $keys, $flags = 0 ) {
$callback = array( $this, 'encodeKey' );
- return $this->client->get_multi( array_map( $callback, $keys ) );
+ $encodedResult = $this->client->get_multi( array_map( $callback, $keys ) );
+ $result = array();
+ foreach ( $encodedResult as $key => $value ) {
+ $key = $this->decodeKey( $key );
+ $result[$key] = $value;
+ }
+ return $result;
}
/**
public function testGetMulti() {
$value1 = array( 'this' => 'is', 'a' => 'test' );
$value2 = array( 'this' => 'is', 'another' => 'test' );
+ $value3 = array( 'testing a key that may be encoded when sent to cache backend' );
$key1 = wfMemcKey( 'test1' );
$key2 = wfMemcKey( 'test2' );
+ $key3 = wfMemcKey( 'will-%-encode' ); // internally, MemcachedBagOStuffs will encode to will-%25-encode
$this->cache->add( $key1, $value1 );
$this->cache->add( $key2, $value2 );
+ $this->cache->add( $key3, $value3 );
$this->assertEquals(
- $this->cache->getMulti( array( $key1, $key2 ) ),
- array( $key1 => $value1, $key2 => $value2 )
+ array( $key1 => $value1, $key2 => $value2, $key3 => $value3 ),
+ $this->cache->getMulti( array( $key1, $key2, $key3 ) )
);
// cleanup
$this->cache->delete( $key1 );
$this->cache->delete( $key2 );
+ $this->cache->delete( $key3 );
}
/**