Caching, how far should one go?
Posted: Tue Oct 07, 2008 9:24 am
I am finally setting up a decent caching system, or at least using zend frameworks caching system. Right now I have it setup on what is just the memory intensive parts, basically these queries that I run on our largest table (~1.4 million rows). This seams like the simplest way to go about this but I know I could go deaper. I have functions that create an array that I can use on my template, each array is different depending on the user and the selected month. This seams like overkill though, caching every single database return and putting it into a serialized array in a tmp file. So, how far should I go?
Just cache the result set for the memory intensive queries?
Cache all queries?
Cache all the arrays that I create for the templates (there are a lot of them)?
The last would be basically caching everything possible, but I imagine that this would make my total cache size huge because every user for every month would have another file for the cache. Also, it seams like I could mess up renewing my cache if I don't have the correct tags set for that cache or if I forget that something may be dependent on something else. Is it wise to just cache it all and hope for the best or what are the best practices for this? I don't want to litter my code with huge cache if statements and then realize that my gain from using the cache is nominal at best. What do you use/suggest?
Just cache the result set for the memory intensive queries?
Cache all queries?
Cache all the arrays that I create for the templates (there are a lot of them)?
The last would be basically caching everything possible, but I imagine that this would make my total cache size huge because every user for every month would have another file for the cache. Also, it seams like I could mess up renewing my cache if I don't have the correct tags set for that cache or if I forget that something may be dependent on something else. Is it wise to just cache it all and hope for the best or what are the best practices for this? I don't want to litter my code with huge cache if statements and then realize that my gain from using the cache is nominal at best. What do you use/suggest?
