/** * @covers WANObjectCache::touchCheckKey() * @covers WANObjectCache::resetCheckKey() * @covers WANObjectCache::getCheckKeyTime() */ public function testTouchKeys() { $key = wfRandomString(); $priorTime = microtime(true); usleep(1); $t0 = $this->cache->getCheckKeyTime($key); $this->assertGreaterThanOrEqual($priorTime, $t0, 'Check key auto-created'); $priorTime = microtime(true); usleep(1); $this->cache->touchCheckKey($key); $t1 = $this->cache->getCheckKeyTime($key); $this->assertGreaterThanOrEqual($priorTime, $t1, 'Check key created'); $t2 = $this->cache->getCheckKeyTime($key); $this->assertEquals($t1, $t2, 'Check key time did not change'); usleep(1); $this->cache->touchCheckKey($key); $t3 = $this->cache->getCheckKeyTime($key); $this->assertGreaterThan($t2, $t3, 'Check key time increased'); $t4 = $this->cache->getCheckKeyTime($key); $this->assertEquals($t3, $t4, 'Check key time did not change'); usleep(1); $this->cache->resetCheckKey($key); $t5 = $this->cache->getCheckKeyTime($key); $this->assertGreaterThan($t4, $t5, 'Check key time increased'); $t6 = $this->cache->getCheckKeyTime($key); $this->assertEquals($t5, $t6, 'Check key time did not change'); }
/** * 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)); } }
/** * Clear all stored messages. Mainly used after a mass rebuild. */ function clear() { $langs = Language::fetchLanguageNames(null, 'mw'); foreach (array_keys($langs) as $code) { # Global and local caches $this->wanCache->touchCheckKey(wfMemcKey('messages', $code)); } $this->mLoadedLanguages = array(); }