CodeIgniter Forums
How to know when to use database caching. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: How to know when to use database caching. (/showthread.php?tid=54841)



How to know when to use database caching. - El Forum - 09-27-2012

[eluser]gwerner[/eluser]
I'm running into a situation where I need to run a query on every page load of a web site. This query really is only doing a check to see if a status has been updated. If it has, then display a message. I'd say that the status will normally be off probably 70% of the time. However, I will still need to check every page load.

Right now I have it setup to autoload the model and I do the call from MY_Controller. Is this the right opportunity to set this up as a cached query? It seems like it might, but I'm not certain when one should implement caching. My understanding is that if a status is updated, I would use that update to clear the cache. That way the next page load will create a new query a recache the data.

Does turning on caching for one query create more of a load than just loading the model and doing the query?

So, should I query every page or cache the query? Thanks in advance for any help.