/** * @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'); }
public function testMcRouterSupport() { $localBag = $this->getMock('EmptyBagOStuff', ['set', 'delete']); $localBag->expects($this->never())->method('set'); $localBag->expects($this->never())->method('delete'); $wanCache = new WANObjectCache(['cache' => $localBag, 'pool' => 'testcache-hash', 'relayer' => new EventRelayerNull([])]); $valFunc = function () { return 1; }; // None of these should use broadcasting commands (e.g. SET, DELETE) $wanCache->get('x'); $wanCache->get('x', $ctl, ['check1']); $wanCache->getMulti(['x', 'y']); $wanCache->getMulti(['x', 'y'], $ctls, ['check2']); $wanCache->getWithSetCallback('p', 30, $valFunc); $wanCache->getCheckKeyTime('zzz'); }