转一段用PHP检查Memcached连接的代码。。。 转载 dervn 2018-08-14 12:25 阅读 214 次 评论 0 条 自己记录一下, 以备不时之需。<?php $mem = new Memcached(); $mem->addServer("127.0.0.1", 11211); #$mem->addServer('/var/www/memcached.sock',0); //$mem->connect("127.0.0.1", 11211); $mem->set('key1', 'This is first value', 60); $val = $mem->get('key1'); echo "Get key1 value: " . $val ."<br />"; $mem->replace('key1', 'This is replace value', 60); $val = $mem->get('key1'); echo "Get key1 value: " . $val . "<br />"; $arr = array('aaa', 'bbb', 'ccc', 'ddd'); $mem->set('key2', $arr, 60); $val2 = $mem->get('key2'); echo "Get key2 value: "; print_r($val2); echo "<br />"; $mem->delete('key1'); $val = $mem->get('key1'); echo "Get key1 value: " . $val . "<br />"; $mem->flush(); $val2 = $mem->get('key2'); echo "Get key2 value: "; print_r($val2); echo "<br />"; $mem->close();效果图 本文地址:https://vps.group/php-memcached-test-20180814.html 温馨提示:文章内容系作者个人观点,不代表VPS小组对观点赞同或支持。 版权声明:本文为转载文章,来源于 dervn ,版权归原作者所有,欢迎分享本文,转载请保留出处! 1人喜欢 赞赏 PREVIOUS:如何给OpenVZ的小鸡添加SWAP NEXT:转载一个测试open_basedir的PHP代码。文章导航