php5-memcached和php5-memcache是两个php操作memcached的组件,他们是不同人开发的。
php官网都列出了他们各自的使用方法:
1. 首先,先安装下apache:
sudo apt-get update
sudo apt-get install apache2
2. 然后安装下php5:
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
3. 接着安装memcached:
sudo apt-get install memcached
4. 接着安装php5-memcached和php5-memcache:
sudo apt-get install php5-memcache
sudo apt-get install php5-memcached
5. 最后重启下apache2:
sudo service apache2 restart
6.编辑test.php内容如下:
memcache vs memcached: 10000 keys
memcached set: 0.7015380859375
memcached get: 0.61220598220825
memcache set: 0.78830289840698
memcache get: 0.74954390525818
~
memcache set: 0.78771591186523
memcache get: 0.75219798088074
memcached set: 0.69968199729919
memcached get: 0.60679888725281
参考文档:
1.https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu