The CodeIgniter framework is a very compact PHP framework. CI has its own database file cache, but according to the official view, the cache setting never expires unless you invoke the method to delete it voluntarily.
Cache files do not expire. Any queries that have been cached'll remain cached until you delete them.
It's so retarded, it's very inconvenient. Modify the DB class, set an expiration time when the cache is turned on, automatically expire automatically when the cache expires.
The 1021 line cache_on function in 1:ci database/db_dirver.php is replaced by the
Copy Code code as follows:
function cache_on ($expire _time=0)//add parm expire time-cache expiration
{
$this->cache_expire_time = $expire _time; Add by Kenvin
$this->cache_on = TRUE;
return TRUE;
}
2:ci database/db_cache.php 90 rows of the Read function if (FALSE = = ($cachedata = Read_file ($filepath))) preceded by a line plus
Copy Code code as follows:
Determine if expiration//Cache_expire_time
if (!file_exists ($filepath)) {
return false;
}
if ($this->db->cache_expire_time > 0 && filemtime ($filepath) db->cache_expire_time) {
return false;
}
In this way, where the cache needs to be opened, the previous $this →db→cache_on (); To
Copy Code code as follows:
$this →db→cache_on ($SEC);
$SEC is the cache expiration time, in seconds. such as $this →db→cache_on (60), which indicates that the cache expires after 60 seconds.