6 class MultiWriteBagOStuffTest
extends MediaWikiTestCase
{
7 /** @var HashBagOStuff */
9 /** @var HashBagOStuff */
11 /** @var MultiWriteBagOStuff */
14 protected function setUp() {
17 $this->cache1
= new HashBagOStuff();
18 $this->cache2
= new HashBagOStuff();
19 $this->cache
= new MultiWriteBagOStuff( array(
20 'caches' => array( $this->cache1
, $this->cache2
),
21 'replication' => 'async'
25 public function testSetImmediate() {
26 $key = wfRandomString();
27 $value = wfRandomString();
28 $this->cache
->set( $key, $value );
31 $this->assertEquals( $value, $this->cache1
->get( $key ), 'Written to tier 1' );
33 $this->assertEquals( $value, $this->cache2
->get( $key ), 'Written to tier 2' );
36 public function testSetDelayed() {
37 $key = wfRandomString();
38 $value = wfRandomString();
40 // XXX: DeferredUpdates bound to transactions in CLI mode
41 $dbw = wfGetDB( DB_MASTER
);
43 $this->cache
->set( $key, $value );
46 $this->assertEquals( $value, $this->cache1
->get( $key ), 'Written to tier 1' );
47 // Not yet set in tier 2
48 $this->assertEquals( false, $this->cache2
->get( $key ), 'Not written to tier 2' );
53 $this->assertEquals( $value, $this->cache2
->get( $key ), 'Written to tier 2' );