您的位置:首页 > 数据库 > Memcache

windows下安装和使用memcached

2013-06-20 00:07 316 查看
memcached 是高效、快速的分布式内存对象缓存系统,主要用于加速 WEB 动态应用程序

Php memcached官方手册地址:http://cn2.php.net/manual/en/memcached.get.php

1. 下载memcached

http://code.jellycan.com/files/ 下载windows下可执行版本的memcached,我下载的是memcached-1.2.6-win32-bin.zip

http://downloads.php.net/pierre/ 下载php_memcache.dll

php_memcache.dll的版本需要与php版本一致

2. 安装memcached

将下载的memcached解压,cmd进入memcached.exe目录

memcached.exe -d install:安装memcached服务

memcached.exe -d start:启动memcached服务

验证: 在进程管理器中能看到memcached进程
在cmd下输入"netstat -ano|findstr 11211",能看到memcached监听

3. 安装php_memcache模块

将下载的php_memcache.dll放到php/ext目录下

修改php.ini,加入"extension=php_memcache.dll"语句

重启apache

查看phpinfo(),已经开启了memcache模块

4. 使用memcached
http://www.cnblogs.com/czh-liyu/archive/2010/04/27/1722084.html
常用命令有set add replace get delete stats flush_all

command <key> <flags> <expiration time> <bytes>

<value>

php中使用memcached

$memcache_obj = new Memcache;

$memcache_obj->connect('localhost', 11211); 

$memcache_obj->set('var_key', 'This is a memcached test!',MEMCACHE_COMPRESSED, 50);

echo $memcache_obj->get('var_key');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Memcached PHP