Welcome to the Linux community forum and interact with 2 million technical staff. The memcached module in php is very useful in actual application development, especially for websites with high traffic volumes, it is mainly used to cache data to the memory and then directly read data from the memory, which will increase the speed by times.
Welcome to the Linux community forum and interact with 2 million technical staff> the memcached module in php is very useful in practical application development, especially for websites with high traffic volumes, the effect is very obvious. Its main function is to cache all data into the memory, and then directly read the data from the memory when used, which will increase the speed by a hundred times, however, this requires
Welcome to the Linux community forum and interact with 2 million technicians>
The memcached module in php is very useful in actual application development, especially for websites with large traffic volumes. Its main function is to cache data into the memory, the read speed will be improved by times when it is used, but this requires the cost of memory usage.
Install the memcached module of php, remove ";" from/etc/php5/conf. d/memcached. ini, restart apache, and run phpinfo () to display memcached information.
Run:
/Usr/local/bin/memcached-d-m 10-u root-l 127.0.0.1-p 11211-c 256-P/tmp/memcached. pid
Memcached service officially started
Memcache: add-add a value. if it already exists, false is returned.
Memcache: addServer-add an available server address
Memcache: close-close a Memcache object
Memcache: connect-create a Memcache object
Memcache_debug-control debugging Function
Memcache: decrement-deletes the value of a saved key.
Memcache: delete-delete a key value
Memcache: flush-Clear All cached data
Memcache: get-get a key value
Memcache: getExtendedStats-obtains the running system statistics of all processes in the process pool.
Memcache: getServerStatus-get the parameters of the running server
Memcache: getStats-return some running statistics of the server
Memcache: getVersion-returns the version information of the running Memcache.
Memcache: increment-adds the value of a saved key.
Memcache: pconnect-creates a persistent connection object for Memcache.
Memcache: replace-R: overwrites an existing key.
Memcache: set-Add a value. if it already exists, overwrite it.
Memcache: setCompressThreshold-compresses data larger than a certain size
Memcache: setServerParams-Modify server parameters at runtime
We recommend that you use an object-oriented method to test this library:
$ Memcache = new Memcache;
$ Memcache-> connect ('localhost', 11211) or die ("cocould not connect ");
$ Version = $ memcache-> getVersion ();
Echo "Server's version:". $ version. "\ n ";
?>
Memcache: The getVersion method returns the version information of the running Memcache.
Memcache: The getStats method is used to return some running statistics of the server. Memcache: The getStats method has three parameters. The first parameter indicates the type to be returned: reset, malloc, maps, cachedump, slabs, items, sizes; the second and third parameters are used when the first parameter is set to "cachedump. Memcache: The getExtendedStats method is used to obtain the running system statistics of all processes in the process pool.
$ Memcache = new Memcache;
$ Memcache-> connect ('localhost', 11211) or die ("cocould not connect ");
Print_r ($ memcache-> getStats ());
/**
* Array
*(
* [Pid] = & gt; 8052
* [Uptime] = & gt; 9205
* [Time] = & gt; 1205898428
* [Version] => 1.2.5
* [Pointer_size] => 32
* [Rusage_user] = & gt; 0.008000
* [Rusage_system] = & gt; 0.000000
* [Curr_items] => 1
* [Total_items] => 17
* [Bytes] => 57
* [Curr_connections] => 2
* [Total_connections] => 15
* [Connection_structures] => 3
* [Cmd_get] => 9
* [Cmd_set] => 23
* [Get_hits] => 5
* [Get_misses] => 4
* [Evictions] => 0
* [Bytes_read] = & gt; 671
* [Bytes_written] = & gt; 850
* [Limit_maxbytes] = & gt; 10485760
* [Threads] => 1
*)
*/
?>
Memcache: the connect method is used to create a Memcache object. Memcache: The pconnect method is used to create a persistent connection object for Memcache. Memcache: the close method is used to close a Memcache object.
[1] [2]