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