PHP MemCached advanced caching application code

高洛峰
Release: 2023-03-04 14:02:02
Original
1104 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 — perform a subtraction operation on the value in a saved key
Memcache::delete — Delete a key value
Memcache::flush — Clear all cached data
Memcache::get — Get a key value
Memcache::getExtendedStats — Get all processes in the process pool Running system statistics
Memcache::getServerStatus — Get the parameters of the running server
Memcache::getStats — Return some running statistics of the server
Memcache::getVersion — Return the version information of the running Memcache
Memcache::increment — Add the value in a saved key
Memcache::pconnect — Create a Memcache persistent connection object
Memcache::replace — R overwrites an existing key Operations
Memcache::set — Add a value, or overwrite if it already exists
Memcache::setCompressThreshold — Compress data larger than a certain size
Memcache::setServerParams — Modify the server at runtime Parameters

Memcache method usage

<?php 
$memcache = new memcache; 
$memcache->connect(&#39;127.0.0.1&#39;, 11211) or die("连接失败"); 
$memcache->set(&#39;name&#39;, &#39;张三&#39;); 
$val = $memcache->get(&#39;name&#39;); 
?>
Copy after login

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

<?php 
$memcache = new memcache; 
$memcache -> connect(&#39;127.0.0.1&#39;, 11211) or die("连接失败"); 
$memcache -> set(&#39;name&#39;, array(&#39;一个&#39;,&#39;两个&#39;)); 
$val = $memcache->get(&#39;name&#39;); 
print_r($val); 
$memcache -> close(); 
?>
Copy after login

More PHP For articles related to MemCached advanced caching application code, please pay attention to the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!