+
+ /**
+ * @covers WANObjectCache::getMulti()
+ */
+ public function testGetWithSeveralCheckKeys() {
+ $key = wfRandomString();
+ $tKey1 = wfRandomString();
+ $tKey2 = wfRandomString();
+ $value = 'meow';
+
+ // Two check keys are newer (given hold-off) than $key, another is older
+ $this->internalCache->set(
+ WANObjectCache::TIME_KEY_PREFIX . $tKey2,
+ WANObjectCache::PURGE_VAL_PREFIX . ( microtime( true ) - 3 )
+ );
+ $this->internalCache->set(
+ WANObjectCache::TIME_KEY_PREFIX . $tKey2,
+ WANObjectCache::PURGE_VAL_PREFIX . ( microtime( true ) - 5 )
+ );
+ $this->internalCache->set(
+ WANObjectCache::TIME_KEY_PREFIX . $tKey1,
+ WANObjectCache::PURGE_VAL_PREFIX . ( microtime( true ) - 30 )
+ );
+ $this->cache->set( $key, $value, 30 );
+
+ $curTTL = null;
+ $v = $this->cache->get( $key, $curTTL, array( $tKey1, $tKey2 ) );
+ $this->assertEquals( $value, $v, "Value matches" );
+ $this->assertLessThan( -5, $curTTL, "Correct CTL" );
+ $this->assertGreaterThan( -5.1, $curTTL, "Correct CTL" );
+ }
+
+ /**
+ * @covers WANObjectCache::set()
+ */
+ public function testSetWithLag() {
+ $value = 1;
+
+ $key = wfRandomString();
+ $opts = array( 'lag' => 300, 'since' => microtime( true ) );
+ $this->cache->set( $key, $value, 30, $opts );
+ $this->assertEquals( $value, $this->cache->get( $key ), "Rep-lagged value written." );
+
+ $key = wfRandomString();
+ $opts = array( 'lag' => 0, 'since' => microtime( true ) - 300 );
+ $this->cache->set( $key, $value, 30, $opts );
+ $this->assertEquals( false, $this->cache->get( $key ), "Trx-lagged value not written." );
+
+ $key = wfRandomString();
+ $opts = array( 'lag' => 5, 'since' => microtime( true ) - 5 );
+ $this->cache->set( $key, $value, 30, $opts );
+ $this->assertEquals( false, $this->cache->get( $key ), "Lagged value not written." );
+ }
+
+ /**
+ * @covers WANObjectCache::set()
+ */
+ public function testWritePending() {
+ $value = 1;
+
+ $key = wfRandomString();
+ $opts = array( 'pending' => true );
+ $this->cache->set( $key, $value, 30, $opts );
+ $this->assertEquals( false, $this->cache->get( $key ), "Pending value not written." );
+ }