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');
source to share
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
source to share
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
source to share
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!
source to share