PHP & 技术 15 Dec 2006 02:51 pm

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的版本要一致。

  1. <?php
  2. $memcache_obj = new Memcache;
  3.  
  4. /* connect to memcached server */
  5. $memcache_obj->connect('localhost', 11211);
  6.  
  7. /*
  8. set value of item with key 'var_key', using on-the-fly compression
  9. expire time is 50 seconds
  10. */
  11. $memcache_obj->set('var_key', 'some really big variable', MEMCACHE_COMPRESSED, 50);
  12.  
  13. echo $memcache_obj->get('var_key');
  14. ?>

显示”some really big variable”就是成功了

Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply