让CodeIgniter数据库缓存自动过期的处理的方法
CachefilesDONOTexpire.Anyqueriesthathavebeencachedwillremaincacheduntilyoudeletethem.
感觉太弱智了,非常不方便。修改一下db类,在开启缓存时设置一个过期时间,到期自动缓存自动失效。
1:CIdatabase/DB_dirver.php中1021行cache_on函数替换为
functioncache_on($expire_time=0)//addparmexpiretime-缓存过期时间
{
$this->cache_expire_time=$expire_time;//addbykenvin
$this->cache_on=TRUE;
returnTRUE;
}2:CIdatabase/DB_cache.php中90行read函数if(FALSE===($cachedata=read_file($filepath)))一行前面加上
//判断是否过期//cache_expire_time
if(!file_exists($filepath)){
returnfalse;
}
if($this->db->cache_expire_time>0&&filemtime($filepath)db->cache_expire_time){
returnfalse;
}这样,在需要开启缓存的地方,由以前的$this→db→cache_on();改为
$this→db→cache_on($SEC);
$SEC为缓存过期时间,以秒为单位。如$this→db→cache_on(60);表示缓存60秒后过期。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下