thinkphp How to write the update cache feature
There's a button in the background to update the cache click on all users (including first visited and previously visited users) to reload the page code
------to solve the idea----------------------
Public Function Ajaxupdatecache () {
if ($this->ispost ()) {
if (file_exists (Runtime_file)) {
Unlink (Runtime_file); Delete Runtime_file;
}
$cachedir = Runtime_path. "/cache/"; The path to the cache file;
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/"; The path to the cache file;
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 ');
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.