Welcome Guest, Not a member yet? Register   Sign In
File Caching does not work
#1

[eluser]Unknown[/eluser]
I load the driver in the constructor:

Code:
public function __construct()
    {
        parent::__construct();
        $this->load->driver('cache');    
    }

I call savetocache:

Code:
public function savetocache()
    {
    
        if ( ! $foo = $this->cache->get('foo'))
        {
             echo 'Saving to the cache!<br />';
             $foo = 'foobarbaz!';

             $this->cache->file->save('foo', $foo, 300);

        }

        echo $foo;    
    }

Output (even if I refresh):

Code:
Saving to the cache!
foobarbaz!

I call testcache:

Code:
public function testcache(){
    
    var_dump($this->cache->get_metadata('foo'));

$foo = $this->cache->get('foo');
    
    echo $foo;
    
    }

Output:

Code:
bool(false)
I go to [app dir]/cache (CHMOD'd 777) and I see a file called "foo", output:

Code:
a:3:{s:4:"time";i:1302827920;s:3:"ttl";i:300;s:4:"data";s:10:"foobarbaz!";}

I'm running Code Igniter 2.0.2 with the following modification:

Quote:Fixed Smile
./system/libraries/Driver.php
from
$filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.EXT;
to
$filepath = $path.'libraries/'.ucfirst($lib_name).'/drivers/'.$class.EXT;

Source: https://bitbucket.org/ellislab/codeignit...cache_file

Please help Sad


Messages In This Thread
File Caching does not work - by El Forum - 04-14-2011, 06:45 PM
File Caching does not work - by El Forum - 04-15-2011, 08:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB