Installation and use of memcached under W7

Source: Internet
Author: User

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

  1. //Connection Memcache
  2. $mem = New Memcache;
  3. $mem ->connect ("localhost", 11211);
  4. //Save Data
  5. $mem ->set (' key1 ', ' This is first value ', 0, $);
  6. $val = $mem ->get (' key1 ');
  7. Echo "Get key1 value:" . $val . "
    ";
  8. //Replace data
  9. $mem ->replace (' key1 ', ' This is replace value ', 0;
  10. $val = $mem ->get (' key1 ');
  11. Echo "Get key1 value:" . $val . "
    ";
  12. //Save array Data
  13. $arr = Array (' aaa', ' bbb', ' CCC', ' ddd ');
  14. $mem ->set (' Key2 ', $arr, 0, each);
  15. $val 2 = $mem ->get (' Key2 ');
  16. Echo "Get key2 value:";
  17. Print_r ($val 2);
  18. Echo "
    ";
  19. //Delete data
  20. $mem - Delete (' key1 ');
  21. $val = $mem ->get (' key1 ');
  22. Echo "Get key1 value:" . $val . "
    ";
  23. //Clear All data
  24. $mem - Flush ();
  25. $val 2 = $mem ->get (' Key2 ');
  26. Echo "Get key2 value:";
  27. Print_r ($val 2);
  28. Echo "
    ";
  29. //Close connection
  30. $mem ->close ();
  31. ?>
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?

  1. //Connection Memcache
  2. $mem = New Memcache;
  3. $mem ->addserver ("localhost", 11211);
  4. $mem ->addserver ("localhost", 11212);
  5. //Save Data
  6. $mem ->set (' key1 ', ' This is first value ', 0, $);
  7. $val = $mem ->get (' key1 ');
  8. Echo "Get key1 value:" . $val . "
    ";
  9. //Save array Data
  10. $arr = Array (' aaa', ' bbb', ' CCC', ' ddd ');
  11. $mem ->set (' Key2 ', $arr, 0, each);
  12. $val 2 = $mem ->get (' Key2 ');
  13. Echo "Get key2 value:";
  14. Print_r ($val 2);
  15. Echo "
    ";
  16. //Delete data
  17. $mem - Delete (' key1 ');
  18. $val = $mem ->get (' key1 ');
  19. Echo "Get key1 value:" . $val . "
    ";
  20. //Close connection
  21. $mem ->close ();
  22. ?>


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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.