• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cacheing not working

I'm playing with the new Cache drivers in Codeigniter and I'm having some troubles. I downloaded the latest code from Codeigniter Reactor. I am using the exact same sample cache code found in the User Guide at http://ellislab.com/codeigniter/user-gui...mple_usage

I have verified both APC is supported and my application/cache/ directory is writable. The problem is, it never caches. If i do var_dump($this->cache->get_metadata('foo')); it returns false. Meaning it used the dummy cache.

If I do something like this everything works just fine:

$driver = 'file';
if ($this->cache->apc->is_supported())
$driver = 'apc';
if ( ! $foo = $this->cache->{$driver}->get('foo'))
echo 'Saving to the cache!<br />';
$foo = 'foobarbaz!';
$this->cache->{$driver}->save('foo', $foo, 300);

Am I missing something or doing something wrong? Is this a bug in the CI code? If this is a bug, does anyone have any idea how to fix this? I've been looking through the Cache code and haven't been able to find any issues yet.

Line 160 in /system/libraries/Cache/drivers/Cache_file.php looks like it's the problem:

Lines 160-171 shown below:
$data = $data['data'];
            $mtime = filemtime($this->_cache_path.$id);

            if ( ! isset($data['ttl']))
                return FALSE;

            return array(
                'expire'     => $mtime + $data['ttl'],
                'mtime'        => $mtime

If I do a print_r of $data, it contains ['ttl']. However assigning $data = $data['data'] does not work here, as it loses the metadata. So the function can never return the array.

Line 160 should be removed / commented out, and then it'll work.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.