public function testRollback()
 {
     $this->cache->set('key', 'value');
     $this->bufferedCache->set('key', 'value-2');
     $this->bufferedCache->add('key2', 'value-2');
     // something else directly sets the key in the meantime...
     $this->cache->set('key2', 'value');
     $this->bufferedCache->commit();
     // both changes should have been "rolled back" and both keys should've
     // been cleared, in both buffered & real cache
     $this->assertEquals(false, $this->bufferedCache->get('key'));
     $this->assertEquals(false, $this->bufferedCache->get('key2'));
     $this->assertEquals(false, $this->cache->get('key'));
     $this->assertEquals(false, $this->cache->get('key2'));
 }
 public function testCompositeShallow()
 {
     global $wgFlowCacheTime;
     $bag = new BufferedBagOStuff(new \HashBagOStuff());
     $cache = new BufferedCache($bag, $wgFlowCacheTime);
     $storage = $this->getMock('Flow\\Data\\ObjectStorage');
     $unique = new UniqueFeatureIndex($cache, $storage, 'unique', array('id', 'ot'));
     $secondary = new TopKIndex($cache, $storage, 'secondary', array('name'), array('shallow' => $unique, 'sort' => 'id'));
     // remember: unique index still stores an array of results to be consistent with other indexes
     // even though, due to uniqueness, there is only one value per set of keys
     $db = FeatureIndex::cachedDbId();
     $v = Container::get('cache.version');
     $bag->set("{$db}:unique:1:9:{$v}", array(array('id' => 1, 'ot' => 9, 'name' => 'foo')));
     $bag->set("{$db}:unique:1:8:{$v}", array(array('id' => 1, 'ot' => 8, 'name' => 'foo')));
     $bag->set("{$db}:unique:3:7:{$v}", array(array('id' => 3, 'ot' => 7, 'name' => 'baz')));
     $bag->set("{$db}:secondary:foo:{$v}", array(array('id' => 1, 'ot' => 9), array('id' => 1, 'ot' => 8)));
     $bag->set("{$db}:secondary:baz:{$v}", array(array('id' => 3, 'ot' => 7)));
     $expect = array(array('id' => 1, 'ot' => 9, 'name' => 'foo'), array('id' => 1, 'ot' => 8, 'name' => 'foo'));
     $this->assertEquals($expect, $secondary->find(array('name' => 'foo')));
     $expect = array(array('id' => 3, 'ot' => 7, 'name' => 'baz'));
     $this->assertEquals($expect, $secondary->find(array('name' => 'baz')));
 }
 /**
  * Roll back all scheduled changes.
  */
 public function rollback()
 {
     $this->cache->rollback();
 }