在PHP中设置分布式memcache存取
//1. 创建对象
$mem = new Memcache();
//2. 添加服务
$mem->addServer("192.168.100.101",11211);
$mem->addServer("192.168.100.102",11211);
$mem->addServer("192.168.100.103",11211);
//3. 放置信息
$mem->add("mystr","hello memcache!",MEMCACHE_COMPRESSED,0);
$mem->add("myarray",array(10,20,30,40),MEMCACHE_COMPRESSED,0);
$mem->add("myob",new Stu(),MEMCACHE_COMPRESSED,0);
//4. 获取信息
echo $mem->get("mystr")."
";
var_dump($mem->get('myarray'));
echo "
";
$mem->get("myob")->getinfo();
已有 0 条评论