Faitas
Faitas

Reputation: 11

Cache problem with CodeIgniter

I have problems with cache in CodeIgniter.

Then I downloaded cache library for CodeIgniter and put in libraries folder, and put php code in controller file:

<?php

class Cache extends CI_Controller
{
    public function index()
    {
        $this->cache->set('test_cache', 'test_cache_content', 300); // 5 minutes
    }
}

?>

This test_cache cache file isn't in cache folder. In config.php file cache_path is default.

Then I want get test_cache content and put code in controller:

<?php

class Cache extends CI_Controller
{
    public function get()
    {
        $data = $this->cache->get('test_cache');
        echo var_dump($data);
    }
}

?>

Then I see null. I was searching about cache in codeigniter, but nothing.

Upvotes: 0

Views: 3532

Answers (1)

cwallenpoole
cwallenpoole

Reputation: 82078

Just to make sure, because it isn't actually in the code above, you did load a caching driver, right:

// example from CodeIgniter Cache docs.
$this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));

Because if you haven't it defaults to the dummy driver. The dummy driver saves nothing, so I don't think you want that.

Upvotes: 2

Related Questions