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 ());? >
?
?