Windows must support memcache and install the memcache server and client:Memcache Server Download,Download the memcache client,
First download the server and decompress it to d disk Directory D: \ memcached-1.2.1-win32, CMD to execute the command:
C/C ++ code Copy content to clipboard
- D: \ memcached-1.2.1-win32
- Memcached.exe-u administator-D install
- Net start"Memcached server"
Will appear
The memcache server has been successfully installed. Haha, then install the memcache client:
Copy the downloaded file to the PHP ext directory, and add a line to the php. ini file in use.
Extension = php_memcache.dll
Restart Apache and check that the memcache module is successfully installed.
Write countCodeTest:
PHP code Copy content to clipboard
- $ mem = New memcache;
- $ mem -> connect ( "localhost" , 11211);
- $ mem -> set ( 'key' , 'value' , 0, 60);
- $ Val = $ mem -> get ( 'key' );
- echo $ Val ; // The output result is "value".
Note: For win7, cmd.exe must run as an administrator; otherwise, the installation will fail. Note: An error may be reported during local testing. Similar:
Notice: memcache: connect () [function. memcache-connect]: Server localhost (TCP 11211) failed with: the connection attempt fails because the connection fails to respond correctly after a period of time or the host does not respond. (10060) in ***/test. php on line 4
Warning: memcache: connect () [function. memcache-connect]: Can't connect to localhost: 11211. The connection attempt fails because the connection fails to respond correctly after a period of time or the host does not respond. (10060) in ***/test. php on line 4
Cocould not connect
Solution:
Replace localhost with 127.0.0.1