一、memcache配置
1. 下载memcache
- 32位系统 1.2.5版本:http://static.runoob.com/download/memcached-1.2.5-win32-bin.zip
- 32位系统 1.2.6版本:http://static.runoob.com/download/memcached-1.2.6-win32-bin.zip
- 32位系统 1.4.4版本:http://static.runoob.com/download/memcached-win32-1.4.4-14.zip
- 64位系统 1.4.4版本:http://static.runoob.com/download/memcached-win64-1.4.4-14.zip
- 32位系统 1.4.5版本:http://static.runoob.com/download/memcached-1.4.5-x86.zip
- 64位系统 1.4.5版本:http://static.runoob.com/download/memcached-1.4.5-amd64.zip
我下载的版本为
2. 解压到如c:\memcached
3. 在命令行输入c:\memcached\memcached.exe -d start 启动memcache
4. 下载php_memcache.dll 找到对应php版本的的文件
5. 在php.ini 加入 extension=php_memcache.dll
6. 重启Apache, 查看phpinfo 中memcache
参考 http://www.runoob.com/memcached/window-install-memcached.html
二、测试连接
<?php
$mem = new Memcache;
$conn = $mem->connect("127.0.0.1",11211); if($conn){
$mem->set('hello','hello world2~',0,60);
$val = $mem->get('hello');
echo $val;
}