예제 #1
0
require __DIR__ . '/../vendor/autoload.php';
$i = 0;
\Amp\repeat(function () use(&$i) {
    echo "\n{$i} iterations";
    $i = 0;
}, 1000);
\Amp\once(function () {
    \Amp\stop();
}, 5000);
\Amp\once(function () {
    \Amp\stop();
}, 10000);
echo "##### SET OP/S";
\Amp\run(function () use(&$i) {
    $memcached = new \Edo\Memcached();
    $memcached->addServer('tcp://127.0.0.1', 11211);
    while (true) {
        $stats = (yield $memcached->set('key', 'value_key'));
        $i++;
    }
});
echo "\n##### GET OP/S";
\Amp\run(function () use(&$i) {
    $memcached = new \Edo\Memcached();
    $memcached->addServer('tcp://127.0.0.1', 11211);
    while (true) {
        $stats = (yield $memcached->get('key'));
        $i++;
    }
});
예제 #2
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);
예제 #3
0
 /**
  * @expectedException \DomainException
  */
 public function testAddConnection()
 {
     $memcached = new \Edo\Memcached();
     $memcached->addServer('file://localhosts', 1);
 }