/** * Invalidate cache keys for modules using this message key. * Called by MessageCache when a message has changed. * * @param string $key Message key */ public function updateMessage($key) { $moduleNames = $this->getResourceLoader()->getModulesByMessage($key); foreach ($moduleNames as $moduleName) { // Uses a holdoff to account for database slave lag (for MessageCache) $this->wanCache->touchCheckKey($this->wanCache->makeKey(__CLASS__, $moduleName)); } }
/** * @dataProvider provideSetAndGet * @covers WANObjectCache::set() * @covers WANObjectCache::get() * @covers WANObjectCache::makeKey() * @param mixed $value * @param integer $ttl */ public function testSetAndGet($value, $ttl) { $curTTL = null; $asOf = null; $key = $this->cache->makeKey('x', wfRandomString()); $this->cache->get($key, $curTTL, [], $asOf); $this->assertNull($curTTL, "Current TTL is null"); $this->assertNull($asOf, "Current as-of-time is infinite"); $t = microtime(true); $this->cache->set($key, $value, $ttl); $this->assertEquals($value, $this->cache->get($key, $curTTL, [], $asOf)); if (is_infinite($ttl) || $ttl == 0) { $this->assertTrue(is_infinite($curTTL), "Current TTL is infinite"); } else { $this->assertGreaterThan(0, $curTTL, "Current TTL > 0"); $this->assertLessThanOrEqual($ttl, $curTTL, "Current TTL < nominal TTL"); } $this->assertGreaterThanOrEqual($t - 1, $asOf, "As-of-time in range of set() time"); $this->assertLessThanOrEqual($t + 1, $asOf, "As-of-time in range of set() time"); }