mysql与memcache结合

来源:互联网 发布:js 自执行函数 编辑:程序博客网 时间:2024/06/11 18:49
<?php/** * @author http://weibo.com/codersay *  * 功能说明:真实数据出库压栈到memcache, * 这里是结合thinkphp使用的,使用时请将该方法放到thinkphp中的某一个控制器中做为其一方法使用 */ function getData($key) {  echo 'after 100s the memcache data expire will clear<br />'; $list = cache($key); if(!$list) { $handler = D('Form'); $list = $handler->where('id = '.$key)->select(); cache($key,$list); echo 'select data,into memcache,return'; return $list; }  echo 'select from memcache'; return $list; }