How to write and update the cache function in thinkphp is that there is a cache update button in the background & nbsp; Click & nbsp; all users (including the first access and & nbsp; previously visited users) & nbsp; reload webpage code & nbsp; ------ solution -------------------- public & nbsp; function & nbsp; how does ajaxUpd thinkphp write and update the cache function?
It means that there is a cache update button in the background to reload the webpage code for all users (including the first and previous users ).
------ Solution ----------------------
Public function ajaxUpdateCache (){
If ($ this-> isPost ()){
If (file_exists (RUNTIME_FILE )){
Unlink (RUNTIME_FILE); // delete RUNTIME_FILE;
}
$ Cachedir = RUNTIME_PATH. "/Cache/"; // Cache file path;
If ($ dh = opendir ($ cachedir) {// open the Cache folder;
While ($ file = readdir ($ dh ))! = False) {// traverse the Cache Directory,
Unlink ($ cachedir. $ file); // delete each file that is traversed;
}
Closedir ($ dh );
}
$ Tempdir = RUNTIME_PATH. "/Temp/"; // Cache file path;
If ($ dh = opendir ($ tempdir) {// open the Cache folder;
While ($ file = readdir ($ dh ))! = False) {// traverse the Cache Directory,
Unlink ($ tempdir. $ file); // delete each file that is traversed;
}
Closedir ($ dh );
}
$ This-> ajaxReturn (array ("success" => true), 'json ');
} Else {
$ This-> ajaxReturn (array ("success" => false, "msg" => "Parameter error"), 'json ');
}
}