memcache缓存服务器01

linux下如何安装memcache服务器

一、安装(安装以前下载解压安装包)php

./configure && make && make install

二、启动python

memcache -d -m 2048 -u root -l 127.0.0.1 -p 11211
#-m 设置内存大小
# -p 设置端口

三、中止linux

pkill memcached

查看memcache服务状态

#查端口
netstat -tunpl |grep 11211
#查进程
pstree |greep memcache

给php安装memcache模块

php要想操做memcache,必须安装相关模块web

#下载包,解压,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();

这里写图片描述