Moein Hosseini
Moein Hosseini

Reputation: 4383

delete CodeIgniter Query Cache

When I make Query Caching in CodeIgniter by $this->db->cache_on(); it will make folder and file,folder named in controller+method for example show+73. but when I delete row which has 73 id,from table and use $this->db->cache_delete('show', $id); to delete cache too,it will not work.It exist and return response when I call show/73 how should I solve it?

my code:

which return result(in model)

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

which delete row and cache from table. (it will delete row from table successfully,but can't delete cache of it)

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;
}

Upvotes: 1

Views: 3547

Answers (2)

stren-12
stren-12

Reputation: 57

delete cash files by

$this->db->cache_delete('show', '73');

for every edit or delete in db

Upvotes: 1

landons
landons

Reputation: 9547

Obvious, but worth ruling out--have you checked file permissions? Also, it caches based on controller/method, so I assume you're doing some re-routing, as this isn't valid php code:

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

Have you tried both the original and rerouted 1st & 2nd URI segments?

That's all I've got, beyond manually checking file_exists(FCPATH.'/path/to/cache/show/73') and unlink()'ing...

Upvotes: 1

Related Questions