}
$purgeValues[] = $purge;
}
+
return $purgeValues;
}
// Wildcards select all matching routes, e.g. the WAN cluster on all DCs
$ok = $this->cache->set(
"/*/{$this->cluster}/{$key}",
- $this->makePurgeValue( $this->getCurrentTime(), self::HOLDOFF_TTL_NONE ),
+ $this->makePurgeValue( $this->getCurrentTime(), $holdoff ),
$ttl
);
} else {
- // This handles the mcrouter and the single-DC case
+ // Some other proxy handles broadcasting or there is only one datacenter
$ok = $this->cache->set(
$key,
- $this->makePurgeValue( $this->getCurrentTime(), self::HOLDOFF_TTL_NONE ),
+ $this->makePurgeValue( $this->getCurrentTime(), $holdoff ),
$ttl
);
}
}
}
+ /**
+ * @covers WANObjectCache::get()
+ * @covers WANObjectCache::processCheckKeys()
+ */
+ public function testCheckKeyHoldoff() {
+ $cache = $this->cache;
+ $key = wfRandomString();
+ $checkKey = wfRandomString();
+
+ $mockWallClock = 1549343530.2053;
+ $cache->setMockTime( $mockWallClock );
+ $cache->touchCheckKey( $checkKey, 8 );
+
+ $mockWallClock += 1;
+ $cache->set( $key, 1, 60 );
+ $this->assertEquals( 1, $cache->get( $key, $curTTL, [ $checkKey ] ) );
+ $this->assertLessThan( 0, $curTTL, "Key in hold-off due to check key" );
+
+ $mockWallClock += 3;
+ $cache->set( $key, 1, 60 );
+ $this->assertEquals( 1, $cache->get( $key, $curTTL, [ $checkKey ] ) );
+ $this->assertLessThan( 0, $curTTL, "Key in hold-off due to check key" );
+
+ $mockWallClock += 10;
+ $cache->set( $key, 1, 60 );
+ $this->assertEquals( 1, $cache->get( $key, $curTTL, [ $checkKey ] ) );
+ $this->assertGreaterThan( 0, $curTTL, "Key not in hold-off due to check key" );
+ }
+
/**
* @covers WANObjectCache::delete
* @covers WANObjectCache::relayDelete