I have to create an exam app that has to load questions that will never change.
According to Documentation
This will cache the query
this->db->cache_on();
$query = $this->db->query("SELECT * FROM mytable");
1.But this is file driver by default right? but how do I make it use APCu by default?
Thanks I hope you can point me in the right direction.
The db->cache_on
is only designed to use file caching. It isn't technically a "file cache" such as OP/APC and is purely handled by some code in the Ci library.
Essentially, when a controller is accessed, the system checks for a version of the cache file that matches the controller and function. If it finds a file, it pulls the result from that instead of calling the DB for the result. If no file is found, it will query the DB and write the file for future queries that match that same call.
If you want to make use of memory / system caching such as APC / OP, you need to use the caching library.
Once loaded, it is access through $this->cache
and not $this->db
Docs on CI are found at:
http://www.codeigniter.com/user_guide/libraries/caching.html
Happy caching!