开发者

Does Codeigniter 2.0 caching driver get loaded each time?

Codeigniters caching documentation recommends:

$this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));

As documented here:

http://codeigniter.com/user_guide/libraries/caching.html

If I load that drive on a single controller, does the driver get loaded each time I call 开发者_Python百科any function in the controller or has the CI framework stored this in memory already?

Thanks!!!


Just do the below steps.

Step 1: Extend the Core Controller

create a file named application/core/MY_Controller.php and place below code in that file.

class MY_Controller extends CI_Controller {

function __construct()
{
    parent::__construct();

// Place the driver calling code here
$this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));

}

}

2.On your application controllers , extend MY_Controller instead of CI_controller

class Welcome extends MY_Controller {

function __construct()
{
    parent::__construct();
}

function index()
{
    $this->load->view('welcome_message');
}

}


If you put the mentioned codes$this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file')); inside the constructor of the controller, it will be loaded each time you call any method of that controller. You don't need to load it inside each method of that controller.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜