Home > php教程 > php手册 > Memcached Cache类

Memcached Cache类

WBOY
Release: 2016-06-07 11:43:23
Original
1131 people have browsed it

最近在学习TP,发现TP下只有memcache的缓存类没有memcached的,就加了一个
代码文件在这里
http://www.thinkphp.cn/extend/485.html

放到TP的Extend/Driver/Cache下,在config.php里配置'DATA_CACHE_TYPE' => 'Memcached',<br> // 'PERSISTENTID'=>'tp',//可选<br> 'MEMCACHED_HOST' => array('127.0.0.1','127.0.0.1'),<br> 'MEMCACHED_PORT' => array('11211','11212'),<br> // 'MEMECACHED_WEIGHT' => array(33,67),//可选使用:和其它缓存一样直接使用S方法就可以S('userName','wahaha',20);<br>         echo 'userName=='.S('userName');<br>         S('user1','wahaha-1',60);<br>         S('user2','wahaha-3',60);<br>         S('user3','wahaha-4',60);<br>         S('user5','wahaha-5',60);<br>         <br>         echo '<br>user1='.S('user1');<br>         echo '<br>user2='.S('user2');<br>         echo '<br>user3='.S('user3');<br>         echo '<br>user5='.S('user5');<br>         // <br>         $memcached = new CacheMemcached();<br>         $data = array(<br>             'key1' => 'value1',<br>             'key2' => 'value2',<br>             'key3' => 'value3',<br>             );<br>         $memcached->setMulti($data,60);<br>         <br>         $key = array('key1','key2','key3');<br>         <br>         p($memcached->getMulti($key));<br>         <br>         $memcached->rm('key2');<br>         <br>         p($memcached->getMulti($key));<br>         <br>         $memcached->set('key88','value88',60);<br>         <br>         p($memcached->get('key88'));<br>         <br>         $memcached->clear();<br>         <br>         p($memcached->getMulti($key));

AD:真正免费,域名+虚机+企业邮箱=0元

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template