1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
--TEST--
memcache->addServer() with microsecond timeout
--SKIPIF--
<?php include 'connect.inc'; ?>
--FILE--
<?php
include 'connect.inc';
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$memcache = new Memcache();
$memcache->addServer($unreachableHost, $unreachablePort, false, 1, 0.1);
$t1 = microtime_float();
$memcache->set('test_key', '1');
$t2 = microtime_float();
$t = $t2 - $t1;
var_dump($t);
var_dump($t > 0.01 && $t < 0.2);
$memcache = new MemcachePool();
$memcache->addServer($unreachableHost, $unreachablePort, 0, true, 1, 0.1);
$t1 = microtime_float();
$memcache->set('test_key', '1');
$t2 = microtime_float();
$t = $t2 - $t1;
var_dump($t);
var_dump($t > 0.01 && $t < 0.2);
$memcache = new MemcachePool();
$t1 = microtime_float();
$memcache->connect($unreachableHost, $unreachablePort, 0, false, 1, 0.1);
$t2 = microtime_float();
$t = $t2 - $t1;
var_dump($t);
var_dump($t > 0.01 && $t < 0.2);
$memcache = new MemcachePool();
$memcache->addServer($unreachableHost, $unreachablePort, 0, true, 1, 1);
$memcache->setServerParams($unreachableHost, $unreachablePort, 0.1);
$t1 = microtime_float();
$memcache->set('test_key', '1');
$t2 = microtime_float();
$t = $t2 - $t1;
var_dump($t);
var_dump($t > 0.01 && $t < 0.2);
?>
--EXPECTF--
Notice: MemcachePool::set(): %s
float(0.%d)
bool(true)
Notice: MemcachePool::set(): %s
float(0.%d)
bool(true)
Notice: MemcachePool::connect(): %s
Warning: MemcachePool::connect(): %s
float(0.%d)
bool(true)
Notice: MemcachePool::set(): %s
float(0.%d)
bool(true)
|