14 if ( $this->
getCliArg(
'use-bagostuff=' ) ) {
43 $callback =
function (
BagOStuff $cache, $key, $existingValue ) use ( &$usleep ) {
47 if ( $existingValue ===
false ) {
51 return $existingValue .
'merged';
55 $merged = $this->
cache->merge( $key, $callback, 0 );
56 $this->assertTrue( $merged );
57 $this->assertEquals( $this->
cache->get( $key ),
'merged' );
60 $merged = $this->
cache->merge( $key, $callback, 0 );
61 $this->assertTrue( $merged );
62 $this->assertEquals( $this->
cache->get( $key ),
'mergedmerged' );
70 $fork = (bool)$this->
getCliArg(
'use-bagostuff=' );
71 $fork &= function_exists(
'pcntl_fork' );
85 $merged = $this->
cache->merge( $key, $callback, 0, 1 );
88 $this->assertFalse( $merged );
92 $this->assertEquals( $this->
cache->get( $key ),
'mergedmergedmerged' );
94 $this->
cache->merge( $key, $callback, 0, 1 );
108 $this->assertTrue( $this->
cache->add( $key,
'test' ) );
116 $this->assertEquals( $this->
cache->get( $key ),
$value );
124 $this->
cache->add( $key, 0 );
125 $this->
cache->incr( $key );
127 $actualValue = $this->
cache->get( $key );
128 $this->assertEquals( $expectedValue, $actualValue,
'Value should be 1 after incrementing' );
132 $value1 =
array(
'this' =>
'is',
'a' =>
'test' );
133 $value2 =
array(
'this' =>
'is',
'another' =>
'test' );
138 $this->
cache->add( $key1, $value1 );
139 $this->
cache->add( $key2, $value2 );
141 $this->assertEquals( $this->
cache->getMulti(
array( $key1, $key2 ) ),
array( $key1 => $value1, $key2 => $value2 ) );
144 $this->
cache->delete( $key1 );
145 $this->
cache->delete( $key2 );