public function run() { $this->initCache(); $repeats = $this->getRepeats(); $bar = new CliProgressBar($repeats); $key = md5('adfjkjkang'); $data = range(0, 10); Cache::setAdapter(MemcacheAdapter::instance()); Cache::set($key, $data); for ($i = 1; $i <= $repeats; ++$i) { Timer::start(); Cache::get($key); Timer::stop(); $bar->update($i); } $this->addResult('Memcache', Timer::get()); $bar = new CliProgressBar($repeats); Cache::setAdapter(MemcachedAdapter::instance()); Timer::reset(); for ($i = 1; $i <= $repeats; ++$i) { Timer::start(); Cache::get($key); Timer::stop(); $bar->update($i); } $this->addResult('Memcached', Timer::get()); Cache::clear(); }
/** * Returns array that contains routes configuration * * @return array */ public function getData() { if (false !== ($data = Cache::get($this->getPrefix()))) { return $data; } $data = $this->config->getData(); Cache::set($this->getPrefix(), $data); return $data; }
/** * @covers Veles\Cache\Adapters\MemcacheAdapter::set */ public function testSet() { $params = []; for ($i = 0; $i < 3; ++$i) { $key = uniqid('VELES::UNIT-TEST::'); $value = uniqid(); $this->object->set($key, $value, 10); $params[] = [$key, $value]; } $msg = 'Wrong MemcacheAdapter::set() result!'; foreach ($params as $param) { list($key, $expected) = $param; $result = Cache::get($key); $this->assertSame($expected, $result, $msg); } }
/** * Check is form submitted by security key presence * @return bool */ public function submitted() { if (!isset($this->data['sid'])) { return false; } $key = $this->name . $this->data['sid']; if (!Cache::get($key)) { return false; } return true; }