public function run()
 {
     $this->initCache();
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     $data = range(0, 99);
     Cache::setAdapter(MemcacheAdapter::instance());
     for ($i = 1; $i <= $repeats; ++$i) {
         $key = sha1(uniqid());
         Timer::start();
         Cache::set($key, $data);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Memcache', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     Cache::setAdapter(MemcachedAdapter::instance());
     for ($i = 1; $i <= $repeats; ++$i) {
         $key = sha1(uniqid());
         Timer::start();
         Cache::set($key, $data);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Memcached', Timer::get());
     Cache::clear();
 }
示例#2
0
 public static final function run()
 {
     self::initCache();
     $repeats = self::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);
     }
     self::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);
     }
     self::addResult('Memcached', Timer::get());
     Cache::clear();
 }
示例#3
0
 /**
  * @covers Veles\Cache\Cache::getAdapter
  * @depends testSetAdapter
  */
 public function testGetAdapter()
 {
     Cache::setAdapter(MemcacheAdapter::instance());
     $result = Cache::getAdapter();
     $this->assertTrue($result instanceof MemcacheAdapter);
     Cache::setAdapter(MemcachedAdapter::instance());
     $result = Cache::getAdapter();
     $this->assertTrue($result instanceof MemcachedAdapter);
 }
 public static function setUpBeforeClass()
 {
     Cache::setAdapter(MemcacheAdapter::instance());
 }