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

[eluser]bubbafoley[/eluser]
try this

Code:
public function __construct()
    {
        parent::__construct();
        $this->load->driver('cache', array('adapter'=>'file'));    
    }

This way you are telling the Cache driver library to use the file adapter by default.

then your function looks like this

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

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

        }

        echo $foo;    
    }

The way you have it now you are using the file adapter to save the cache but not to retrieve it.


If you don't pass a default adapter when loading the driver, you have to specify which adapter to use each time.

Code:
$this->load->driver('cache'); // using dummy cache by default
$this->cache->file->get('foo');
$this->cache->file->save('foo', $foo);


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