Download Windows 64-bit MEMCACHED:HTTP://PAN.BAIDU.COM/S/1NTDRJA5
1, unpack the first package under a disk, for example, in c:\memcached.
2. Enter the ' c:\memcached\memcached.exe-d install ' installation in the terminal (also known as CMD Command interface).
3, re-enter: ' c:\memcached\memcached.exe-d start ' start. (Note: memcached will start automatically every time a service is turned on for Windows.) This way the server side is already installed).
4. Download the Php_memcache.dll file and put it in the ext directory of the PHP folder.
5. Add a one-line reference extension to the php.ini code as follows:
Extension=php_memcache.dll
6. Then add the following in the php.ini file:
It's best to put it under the "Extension=php_memcache.dll" just now. (This is some of the default configurations)
7, restart Apache, and then check the phpinfo, if there are memcache instructions, then the installation is successful!
8, write a example.php file (more ways to use the PHP manual to see the Memcache Functions instructions), the test code is as follows:
<?php $memcache = new Memcache;//Create a Memcache object $memcache->connect (' localhost ', 11211) or Die ("Could Not connect "); Connect the memcached server $memcache->set (' key ', ' test ');//set a variable into memory, the name is the key value is Test $get _value = $memcache Get (' key '); Remove the value of key from memory Echo $get _value; ? >
9. Common operation
<?php //Connection Memcache $mem = new Memcache; $mem->connect ("localhost", 11211); Save Data $mem->set (' key1 ', ' This is first value ', 0,); $val = $mem->get (' Key1 '); echo "Get Key1 value:". $val. " <br> "; Replacement data $mem->replace (' key1 ', ' This is replace value ', 0,.); $val = $mem->get (' Key1 '); echo "Get Key1 value:". $val. "<br>"; Save array Data $arr = Array (' AAA ', ' BBB ', ' CCC ', ' ddd '); $mem->set (' Key2 ', $arr, 0,); $val 2 = $mem->get (' Key2 '); echo "Get Key2 value:"; Print_r ($val 2); echo "<br>"; Delete Data $mem->delete (' Key1 '); $val = $mem->get (' Key1 '); echo "Get Key1 value:". $val. "<br>"; Clear all data $mem->flush (); $val 2 = $mem->get (' Key2 '); echo "Get Key2 value:"; Print_r ($val 2); echo "<br>"; Close connection $mem->close ();
Installation configuration for memcached under Windows