一、memcache安装

php memcache扩展的安装:


wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar zvxf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure
make
make install
wget http://pecl.php.net/get/memcached-2.2.0.tgz


tar zvxf memcached-2.2.0.tgz

cd memcached-2.2.0
/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config


注意:如果error:no,sasl.h is not available 错误就加上这个 项
./configure  --disable-memcached-sasl --with-php-config=/usr/local/php/bin/php-config

make

make install

在vi /usr/local/php/etc/php.ini

添加 extension=memcached.so ,然后重新启动php就ok

二、memcache命令的使用

登录memcache: telnet 127.0.0.1 11211

1、列出所有的keys
输入:stats items
出现:
STAT items:7:number 1
STAT items:7:age 188
END

2、接下来基于列出的items id,本例中为7,第2个参数为列出的长度,0为全部列出
输入:
stats cachedump 7 0
出现:
ITEM Sess_sidsvpc1473t1np08qnkvhf6j2 [183 b; 1394527347 s]
END


3、获取具体的值:

输入:get Sess_sidsvpc1473t1np08qnkvhf6j2

就可以得到所有的值