PHPMemCached advanced cache application code

Source: Internet
Author: User
For more information about PHPMemCached advanced cache applications, see. Memcache

Common Memcache methods

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
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

Memcache method usage

The code is as follows:
$ Memcache = new memcache;
$ Memcache-> connect ('127. 0.0.1 ', 127) or die ("connection failed ");
$ Memcache-> set ('name', 'Zhang San ');
$ Val = $ memcache-> get ('name ');
?>

Note: The complete version of the set method, set (key name, key value, whether to compress, retention time)

The code is as follows:
$ Memcache = new memcache;
$ Memcache-> connect ('127. 0.0.1 ', 127) or die ("connection failed ");
$ Memcache-> set ('name', array ('one', 'two '));
$ Val = $ memcache-> get ('name ');
Print_r ($ val );
$ Memcache-> close ();
?>
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.