Пример #1
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$iterator = 0;
echo get_class(\Amp\reactor()) . "\n";
$operations = 10000;
$values = array();
for ($iterator = 0; $iterator < $operations; $iterator++) {
    $values[sprintf('%020s', $iterator)] = sha1($iterator);
}
\Amp\run(function () use(&$i, $values) {
    $memcached = new \Edo\Memcached();
    $memcached->addServer('tcp://127.0.0.1', 11211);
    $start = microtime(true);
    foreach ($values as $k => $v) {
        $stats = (yield $memcached->set($k, $v, 3600));
    }
    $time = microtime(true) - $start;
    echo "amp-memcached set: {$time}\n";
    $start = microtime(true);
    foreach ($values as $k => $v) {
        $stats = (yield $memcached->get($k));
    }
    $time = microtime(true) - $start;
    echo "amp-memcached get: {$time}\n";
    \Amp\stop();
});
if (extension_loaded('memcache')) {
    $memached = new Memcache();
    $memached->addServer('127.0.0.1', 11211);
    $start = microtime(true);
Пример #2
0
 /**
  * @expectedException \DomainException
  */
 public function testAddConnection()
 {
     $memcached = new \Edo\Memcached();
     $memcached->addServer('file://localhosts', 1);
 }