Cache library not loading
I got an error while loading the cache library in codeigniter (2.1.3). This says the following:
Error detected
Unable to load requested class: cache
My code looks like this
if (!$data['foo'] = $this->cache->file->get('details')) {
$data['foo'] = $this->foo->getdetails();
$this->cache->file->save('details', $data['foo'], 600);
}
My startup file looks like this:
$autoload['libraries'] = array('database','form_validation','session','driver','cache');
Hi everyone, I have an answer to this problem.
Finally, I created a custom library and called the startup file. it solved my problem.
and the code is here
class CallCache {
public function __construct($config = array())
{
$ci = &get_instance();
$ci->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));
}
}
Finally, thank God
make sure you are not missing the CI library loading function ... it looks like you are not loading the class.
In any of your Controller functions, you can initialize your class using the standard one: $ this-> load-> library ('someclass');
try it
$this->load->library('cache'); //library name // put it on your controller..
here is useguide
I think you need to load the cache library earlier. You can do it like this:
$this->load->library('cache');
Or you can put the cache library in your autoload.php file
The solution for me was to rename the folder name from: "libraries / cache" to "libraries / Cache" in the system folder :)
Loader uses ucfirst () to enter the name of the first letter of the first letter and search in it to find the driver.
what about comparing php versions on both your local and server. I did this a while ago regarding utf-8 encoding and it turned out that CI cannot work well if your php version is lower than 5.4 or native. You will have to update it in cpanel or whatever your server is using. Hooray!