I am using the cache concept first time in codeigniter.I just followed the guidelines specified in codeigniter tutorials.But cache is not clearing after the time specified.Code is as follows:
$this->load->driver('cache');
if ( ! $foo = $this->cache->get('foo'))
{
echo 'Saving to the cache!<br />';
$foo = 'foobarbaz!';
$this->cache->save('foo', $foo, 120);
}
echo $foo;
After two minutes what will be the value of $foo? Whether i have to do any other settings?
$cache = $this->cache->get('cache_data');
if ($cache) {
echo $data = $this->cache->get('cache_data');
} else {
echo 'Cache is not set';
$this->cache->save('cache_data','data',3600);
}
I tried this code also.But every time it will execute the else part.
if ( ! $data = $this->cache->get('cache_data'))
{
$data = array();// your data
$this->cache->save('cache_data', $data, 600000);
}