Hello there.
I'm a new user of FuelPHP Framework and i really don't know how the caching of the queries work on FuelPHP. Let me explain a little bit my situation.
Last night, i've started to coding a new website mainly about sport stats and so. My concern is the following: when people click for example a link to see a "X soccer match" from a "Y Tournament" from a "Z Year", it will display data like:
- referee name
- goal scorers
- startups (of both teams)
- substitutions
- red cards
- yellow cards
- bla
- and more blah
So, let's suppose i have 1,000 visitors at same time looking the exactly same "X match, Y tournament, Z year". Does the query is cached the first time is called? Or every person who clicks on the link will query all that info from database? Obviously, that will be ultra heavily on resources, so, how does caching works? Is it some automagical? or i need to code up how to handle that inside controllers?
Thanks for your help. Im coming from CI (as a lot of people). Just played with OIL and it was love at first sight.
Have a nice day!
FuelPHP's database layer doesn't case automatically, it only does that when you tell it to.
See http://docs.fuelphp.com/classes/database/usage.html#caching
This will use the Cache class, so you have to make sure that is configured properly (by copying core/config/cache.php to app/config and modify it with your preferred cache storage config).
If you don't specify a cache key, one will be generated based on the SQL of the current query.
Thanks a lot for pointing me how to use it, Harro.
I was watching FuelPHP Essentials by Phil at Tuts+ and all this cache thing came up to my mind.
One last question, when is a good time to use cache? How may i know if im using a lot of resources? I gave an example in my first post but maybe that's an easy task for the server to handle so caching is not needed.
Thanks and sorry for too many questions. I want to start coding the right way since day one.