windows下安装memcached
memcached官网
http://www.danga.com/memcached/
memcached windows官网
http://jehiah.cz/projects/memcached-win32/
memcached 1.2.0 for Win32为最新版,需libevent 1.2
Unzip the binaries in your desired directory (eg. c:\memcached)
Install the service using the command: ‘c:\memcached\memcached.exe -d install’ from either the command line
Start the server from the Microsoft Management Console or by running the following command: ‘c:\memcached\memcached.exe -d start’
Use the server, by default listening to port 11211
Use ‘memcached.exe -h’ for extra help and command line server
以后memcached将作为windows的一个服务每次开机时自动启动。
在php.ini 去掉 ‘extension=php_memcache.dll’前的注释
下载pecl的memcache模块包到ext目录
NOTE: php和pecl的版本要一致。
- <?php
- $memcache_obj = new Memcache;
- /* connect to memcached server */
- $memcache_obj->connect('localhost', 11211);
- /*
- set value of item with key 'var_key', using on-the-fly compression
- expire time is 50 seconds
- */
- $memcache_obj->set('var_key', 'some really big variable', MEMCACHE_COMPRESSED, 50);
- echo $memcache_obj->get('var_key');
- ?>
显示”some really big variable”就是成功了