PHP Internal Memory Cache Technology

Source: Internet
Author: User
PHP Memory Caching Technology

In many occasions, will hear memcached this name, but just heard, and have not used or actually understand, only know it is a very good stuff. As a brief introduction, memcached is an efficient and fast distributed memory object caching system, which is mainly used to accelerate WEB dynamic applications. Recently learned the next memcached

The first is the download memcached,windows and Linux version of all, run the memcached daemon is very simple, just a command line, no need to modify any configuration file:

/usr/bin/memcached-d-M 128-l 192.168.1.1-p 11211-u httpd

Parameter explanation:

-D runs memcached in the daemon (daemon) mode;

-M set PHP memory cache technology memcached can use the memory size, in units of M;

-L Set the listening IP address, if it is native, it is usually possible not to set this parameter;

-P Sets the listening port, which defaults to 11211, so you can also not set this parameter;

-u Specifies the user.

 
  Connect (' localhost ', 11211) or Die ("Could not Connect");//Connection memcache$version = $memcache->getversion ();// Get the memcache version of echo "Server S version:". $version. "
"; $tmp _object = 123;if ($memcache->get (' key ')) { $memcache->increment (' key ', 2); $va = $memcache->get (' key '); echo $va;//variable self-increment, variable stored in memory, modified to keep modified var_dump ($memcache->getstats ()); Exit ();} $memcache->add (' key ', $tmp _object, False, or Die ("Failed-to-save data at the server"); echo "Store data in the cache (data would expire in seconds)
"; $get _result = $memcache->get (' key '); echo" Data from the cache:
"; Var_dump ($get _result); Var_dump ($memcache->getstats ());? >

?

?

  • Related Article

    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.