开发环境win下面配置使用Memcached方法概述 再简单的事情没有做一遍都不能明白其中时候如此,今天配置Memcached就发现这个问题。帮助很全,先是在memcached for Windows获取到了需要的win下面的Memcached,按照方法:
引用
Unzip the binaries in your desired directory (eg. c:memcached)
Install the service using the command: 'c:memcachedmemcached.exe -d install' from the command line
Start the server from the Microsoft Management Console or by running the following command: 'c:memcachedmemcached.exe -d start'
Use the server, by default listening to port 11211
然后
在php.ini 加入一行 'extension=php_memcache.dll'
然后到 http://pecl4win.php.net/ext.php/php_memcache.dll获取php_memcache.dll
并复制到 ext 中(记住版本不要错了!)
重启Apache,发现PHPInfo就是提示出不来memcache,真是无语了,代码测试总是提示
引用
Fatal error: Class 'Memcache' not found in D:xampplitehtdocsmemcacheindex.php on line 20
开始觉得奇怪,于是搜索在官方网站发现了http://www.php.net/manual/zh/ref.memcache.php
Hi there:
For run memcached in a windows box: (tested with latest php,apache and memcache in xp sp2)
a) download the php_memcache.dll it can be found in the pecl file.
b) put the dll in the extension folder (c:/php/extension for example). You cannot miss this folder because they are filled with php*.dll files. In some cases the extension folder used is the system32, a non-standard way to put dll but still works.
c)configure the php.ini
; i put this like the latest extension
extension=php_memcache.dll
; i'm not sure about this but don't hurts..
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
memcache.default_port = 11211
d)This is important, memcached works with a EXTERNAL service. This service must be downloaded and installed prior to use the memcache. I use: http://jehiah.cz/projects/memcached-win32/
e)Remember to install the service and to start the service memcached.exe -d install for install and run services.msc for start the memcached service (or restart the system).
f) check the firewall ports.
Finally restart the apache/iis and runs some test. At least in phpinfo must show some info about the memcache.
Final notes :The "awe" about memcache is not only can help for speed some process (or reduce the cpu use), also can be used like a global session for store a whole object also this "global session" is shared among all the users, like APPLICATION used in ASP. So (for example) it's possible to do a user counter without needing of database or writing a file.
试试态度加上看了一下,看到了熟悉的东西了: view plaincopy to clipboardprint?
$mem=newMemcache;
$mem->connect('127.0.0.1',11211);