The CodeIgniter framework is a very small PHP framework. The CI comes with the database file cache, but according to the official statement, the cache will never expire unless you invoke the method to delete it actively.
Cache files do not expire. Any queries that has been cached would remain cached until you delete them.
Feel too retarded, very inconvenient. Modify the DB class to set an expiration time when the cache is turned on, and the expiration auto-cache automatically expires.
1:ci database/db_dirver.php 1021 rows cache_on function is replaced by
Copy CodeThe code is 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-line read function if (FALSE = = = ($cachedata = Read_file ($filepath))) a line preceded by a
Copy CodeThe code is as follows://Determine whether to expire//Cache_expire_time
if (!file_exists ($filepath)) {
return false;
}
if ($this->db->cache_expire_time > 0 && filemtime ($filepath) db->cache_expire_time) {
return false;
}
Thus, where the cache needs to be opened, the previous $this →db→cache_on (); Switch
Copy CodeThe code is as follows: $this →db→cache_on ($SEC);
The $SEC is the cache expiration time, in seconds. such as $this →db→cache_on (60); Indicates that the cache expires after 60 seconds.
http://www.bkjia.com/PHPjc/788633.html www.bkjia.com true http://www.bkjia.com/PHPjc/788633.html techarticle The CodeIgniter Framework is a very small PHP framework. The CI comes with the database file cache, but according to the official statement, the cache will never expire unless you invoke the method to delete it actively. Cache ...