$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."\n<br>";
$tmp_object = 'test';
$memcache->set('key', $tmp_object, false,10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)\n";
$get_result = $memcache->get('key');
echo "Data from the cache:\n";
var_dump($get_result);
运行结果显示:
Notice: MemcachePool::getversion(): Server 127.0.0.1 (tcp 11211, udp 0) failed with: Network timeout (0) in /alidata/hualian_ezhan/test.php on line 7
Server's version:
长风秋雁