您好,欢迎访问一九零五行业门户网

thinkphp如何写更新缓存功能

thinkphp怎么写更新缓存功能
就是后台有个更新缓存的按钮 点击一下  所有用户(包括第一次访问的和 以前访问过的用户)  重新加载网页代码
------解决思路----------------------
public function ajaxupdatecache() {
        if ($this->ispost()) {
            if (file_exists(runtime_file)) {
                unlink(runtime_file); //删除runtime_file;
            }
            $cachedir = runtime_path . /cache/;   //cache文件的路径;
            if ($dh = opendir($cachedir)) {     //打开cache文件夹;
                while (($file = readdir($dh)) !== false) {    //遍历cache目录,
                    unlink($cachedir . $file);                //删除遍历到的每一个文件;
                }
                closedir($dh);
            }
            $tempdir = runtime_path . /temp/;   //cache文件的路径;
            if ($dh = opendir($tempdir)) {     //打开cache文件夹;
                while (($file = readdir($dh)) !== false) {    //遍历cache目录,
                    unlink($tempdir . $file);                 //删除遍历到的每一个文件;
                }
                closedir($dh);
            }
            $this->ajaxreturn(array(success => true), 'json');
        } else {
            $this->ajaxreturn(array(success => false, msg => 参数错误), 'json');
        }
    }
其它类似信息

推荐信息