Home > Backend Development > PHP Tutorial > memcache PHP MemCached advanced caching application code

memcache PHP MemCached advanced caching application code

WBOY
Release: 2016-07-29 08:43:25
Original
1009 people have browsed it

Memcache common methods
Memcache::add — Add a value, if it already exists, return false
Memcache::addServer — Add a server address for use
Memcache::close — Close a Memcache object
Memcache::connect — Create a Memcache object
Memcache::debug — Control the debugging function
Memcache::decrement — Subtract the value in a saved key
Memcache::delete — Delete a key value
Memcache::flush — Clear all caches Data
Memcache::get — Get a key value
Memcache::getExtendedStats — Get the running system statistics of all processes in the process pool
Memcache::getServerStatus — Get the parameters of the running server
Memcache::getStats — Return some operations of the server Statistics
Memcache::getVersion — Returns the version information of the running Memcache
Memcache::increment — Adds the value in a saved key
Memcache::pconnect — Creates a Memcache persistent connection object
Memcache:: replace — R overwrites an existing key
Memcache::set — Adds a value, and if it already exists, overwrites it
Memcache::setCompressThreshold — Compresses data larger than a certain size
Memcache::setServerParams — Modify the parameters of the server at runtime
Memcache method uses

to copy the code The code is as follows:


$memcache = new memcache;
$memcache->connect('127.0.0.1' , 11211) 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 or not, retention time)

Copy the code The code is as follows:


$memcache = new memcache;
$memcache -> connect('127.0.0.1', 11211) or die("Connection failed");
$memcache -> set('name', array('one','two'));
$val = $memcache->get('name');
print_r($val);
$memcache -> close();
?>

The above introduces memcache PHP MemCached advanced caching application code, including memcache content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template