How does thinkphp write and update the cache function?

Source: Internet
Author: User
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 ');
}
}

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.