作業系統:Linux
1.安裝memcached yum install memcached
2.啟動memcached
service memcached start
3.安裝PHP memcache extension
yum install php-pecl-memcache
4.重新啟動http server
service httpd restart
5.PHP測試memcached
<?PHP
$memcache = new Memcache; //Star memcache
$memcache->connect('localhost', 11211) or die ("Could not connect"); //Connect Memcached
$memcache->set('uname', 'appleboy');
$get_value = $memcache->get('uname');
echo $get_value;
print "<br/>";
$b = $memcache->getStats();
print_r($b);exit; ?>
參考資料:
http://blog.wu-boy.com/2007/09/freebsd-%E5%AE%89%E8%A3%9D-memcache-for-php/