gpt4 book ai didi

php - 删除 CodeIgniter 查询缓存

转载 作者:行者123 更新时间:2023-11-29 07:04:36 26 4
gpt4 key购买 nike

当我通过 $this->db->cache_on(); 在 CodeIgniter 中创建查询缓存时,它将创建文件夹和文件,文件夹在 controller+method 中命名为例如 show+73。但是当我从表中删除具有 73 id 的行并使用 $this->db->cache_delete('show', $id); 也删除缓存时,它将不起作用。它存在并在我调用 show/73 时返回响应我该如何解决?

我的代码:

返回结果(在模型中)

public function temp($id)
{
$this->db->cache_on();
$this->db->where('id',$id);
$query = $this->db->get('system_store_table');
return $query->result();
}

从表中删除行和缓存。 (它会成功从表中删除行,但不能删除它的缓存)

public function delete($id = 0)
{
$this->db->flush_cache();
$this->db->where('id',$id);
$this->db->delete('system_store_table');
$this->db->cache_delete('show', $id);
if ($this->db->affected_rows() != 0)
return TRUE;
return FALSE;
}

最佳答案

很明显,但值得排除——你检查过文件权限了吗?此外,它基于 Controller /方法进行缓存,所以我假设你正在做一些重新路由,因为这不是有效的 php 代码:

class Show extends CI_Controller {
public function 73() {
}
}

您是否尝试过原始和重新路由的第一个和第二个 URI 段?

这就是我所拥有的,除了手动检查 file_exists(FCPATH.'/path/to/cache/show/73') 和 unlink()'ing...

关于php - 删除 CodeIgniter 查询缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8137217/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com