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!
If not found in PHP configuration after reboot, probably is DLL file and installed Mamcache version mismatch
-
- //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 . "
";
- //Replace data
- $mem ->replace (' key1 ', ' This is replace value ', 0;
- $val = $mem ->get (' key1 ');
- Echo "Get key1 value:" . $val . "
";
- //Save array Data
- $arr = Array (' aaa', ' bbb', ' CCC', ' ddd ');
- $mem ->set (' Key2 ', $arr, 0, each);
- $val 2 = $mem ->get (' Key2 ');
- Echo "Get key2 value:";
- Print_r ($val 2);
- Echo "
";
- //Delete data
- $mem - Delete (' key1 ');
- $val = $mem ->get (' key1 ');
- Echo "Get key1 value:" . $val . "
";
- //Clear All data
- $mem - Flush ();
- $val 2 = $mem ->get (' Key2 ');
- Echo "Get key2 value:";
- Print_r ($val 2);
- Echo "
";
- //Close connection
- $mem ->close ();
- ?>
To enable one or more processes on one or more machines, this is the start of a machine
With two processes, two ports are used:
#./memcached-d-u nobody-m 127.0.0.1-p 11211
#./memcached-d-u nobody-m 127.0.0.1-p 11212
SOURCE print?
-
- //Connection Memcache
- $mem = New Memcache;
- $mem ->addserver ("localhost", 11211);
- $mem ->addserver ("localhost", 11212);
- //Save Data
- $mem ->set (' key1 ', ' This is first value ', 0, $);
- $val = $mem ->get (' key1 ');
- Echo "Get key1 value:" . $val . "
";
- //Save array Data
- $arr = Array (' aaa', ' bbb', ' CCC', ' ddd ');
- $mem ->set (' Key2 ', $arr, 0, each);
- $val 2 = $mem ->get (' Key2 ');
- Echo "Get key2 value:";
- Print_r ($val 2);
- Echo "
";
- //Delete data
- $mem - Delete (' key1 ');
- $val = $mem ->get (' key1 ');
- Echo "Get key1 value:" . $val . "
";
- //Close connection
- $mem ->close ();
- ?>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the installation and use of memcached under W7, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.