linux下如何安装memcache服务器
1、安装(安装之前下载解压安装包)
./configure && make && make install
2、启动
memcache -d -m 2048 -u root -l 127.0.0.1 -p 11211
#-m 设置内存大小
# -p 设置端口
3、停止
pkill memcached
查看memcache服务状态
#查端口
netstat -tunpl |grep 11211
#查进程
pstree |greep memcache
给php安装memcache模块
php要想操作memcache,必须安装相关模块
#下载包,解压,cd到该目录下
phpize
./configure -h #-h是用来查看帮助的
./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config
#--with-php-config 的路径不能错
php操作memcache
#连接
$mem = new Memcache;
$mem->connect('localhost','11211');
#增
$mem->set('username','123');
#删
$mem->delete('username');
#查
$mem->get('username');
#清空
$mem->flush();
#获取状态
$mem->getStats();