Home > Backend Development > PHP Tutorial > How to operate memcache cache in php? Please provide the specific code? Ask God for answers

How to operate memcache cache in php? Please provide the specific code? Ask God for answers

WBOY
Release: 2016-08-04 09:20:28
Original
1138 people have browsed it

How to operate memcache cache in php? Please provide the specific code? Ask God for answers


Duplicate:
https://segmentfault.com/q/10...

Reply content:

How to operate memcache cache in php? Please provide the specific code? Ask God for answers


Duplicate:
https://segmentfault.com/q/10...

Those who hold out their hands are the most annoying! ! ! Wouldn’t you use Baidu and Google first? ? ?
PHP official manual memcahce
PHP official manual memcached

The specific code still depends on personal habits! As long as you enable the memcache extension. You can also re-encapsulate a memcache class call that suits you, or you can just use the built-in function without encapsulation. Examples of directly calling built-in functions are as follows

<code>//连接
$cache = new Memcache;
$cache->connect("cache.example.net", 12000);
//保存数据
$cache->set('keySave', 'This is first value', 0, 60);
$val = $cache->get('keySave');
echo "Get keySave value: " . $val ."<br />";
//删除数据
$cache->delete('keySave');
$val = $cache->get('keySave');
echo "Get keySave value: " . $val . "<br />";
//关闭连接
$cache->close();</code>
Copy after login

For reference only, hope it helps you

Related labels:
php
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