thinkphp使用文件缓存的实例

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 16:56   2702   0


中间省略了设置

缓存的前缀是md5的传入参数

$input = I('get.');

// cache instance
$prefix = 'matching_index' . md5(__METHOD__ . serialize($input));
$Cache = Cache::getInstance('File', array('expire' => '600', 'prefix' => $prefix));

// check cache
if ($user_show = $Cache->get('user_show')) {
    var_dump('有缓存的情况');
    $total_data = $Cache->get('total_data');
    $user_list = $Cache->get('user_list');
    $input = $Cache->get('input');
    $Page = $Cache->get('page');

} else {

    // there is no cache
    var_dump('没有缓存的情况');
    $stat_show = $this->listShowWithNoCache($Cache);
    $total_data = $stat_show['total_data'];
    $user_show = $stat_show['user_show'];
    $user_list = $stat_show['user_list'];
    $input = $stat_show['input'];
    $Page = $stat_show['page'];
}

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP