CodeIgniter Cache Issues

Well! This is actually not an issues of CodeIgniter cache system. It's how I wrongly use the cache function.

Whenever you use db->cache_on() function to cache the current query. It will cache all the executed queries from this point for the rest of queries in the whole PHP page.

In other words, it will cache everything query that do not have db->cache_off(). WOW! What a big mistake.

So if you just want to cache the current query execution, remember to put db->cache_off() after executing the query. Always remember that!

for example:
$this->pf_db->db->cache_on();
$result = $this->pf_db->db->query($query);
$this->pf_db->db->cache_off();
Without the cache_off(), all the queries after this one will be cached!
Post a Comment