2.0.2 버전을 다운 받아 운영중인 사이트 전환 작업을 CodeIgniter 로 처음으로 하고 있습니다.
메인 페이지를 widget 을 이용해서 뿌려 주고 이를 캐싱 해서 사용하고자 하는데 캐싱이 되지 않고 매번 실행이 되어 결과가 뿌려지네요.
$this->load->driver('cache', array('adapter' => 'file'));//, array('adapter' => 'apc', 'adapter'=>'file'));//
if(!$mainitem= $this->cache->get('mainitem'))
{
$data = $this->getItem();
$mainitem = $this->render("mainitem", $data);
// Save into the cache for 5 minutes
$this->cache->save('mainitem', $mainitem, 300);
}
echo $mainitem;
설정이 잘못되어 있을까요?
/* |-------------------------------------------------------------------------- | Cache Directory Path |-------------------------------------------------------------------------- | | Leave this BLANK unless you would like to set something other than the default | system/cache/ folder. Use a full server path with trailing slash. | */ $config['cache_path']
$cachename = 'main';
if (! $main = $this->cache->get($cachename))
{
ob_start();
$this->load->view('main');
$main = ob_get_contents();
ob_end_clean();
$this->cache->save($cachename, $main, 300);
}
echo $main;
$this->load->view('main', '', true);
이렇게 하시면 받아질겁니다. 매뉴얼에 그렇게 나와있네요.까리쓰마 님 감사합니다.
또 하나의 길이 열렸네요.
$this->load->view('main', '', true);
로 하는건 캐싱이 아니라 출력 방향을 브라우져로 보내는게 아니라 리턴 하는 형태로 처리하라는것 아닌가요?
제가 이제 메뉴얼을 보며 공부하는 단계라 몰라서요. ^^;