CI 묻고 답하기

제목 초보입니다. 캐시문제 어디를 봐야할까요?
글쓴이 솔해 작성시각 2014/01/11 16:53:41
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 16674   RSS
 codeigniter를 이번에 처음 알았네요.

이곳에서 검색하며 많은 도움이 되었습니다. 검색으로도 찾을수 없어 이렇게 질문 드립니다.

현제 간단한 쇼핑탭 추가작업 90%작업 되었는데 캐시문제가 해결되지 않네요. 똑같은 컨트롤과 똑같은 모듈로 데이타를 받아오는데 관리자쪽 상품리스트에선 캐시가 적용되지않고 수정된부분이 바로 적용되는데(주문이 들어오면 잔여수량과 판매갯수가 변동되도록...)  사용자 상품리스트에선 주문된 데이타가 반영되지않고 캐시에 저장된 데이터가 바로 나오는것 같습니다. 어디를 손봐야할지 도움주시면 고맙겠습니다.

컨트롤 소스
-----------------------------------------------------------------------
function lists()
{
$this->db->cache_delete_all();
// 페이지당 게시물.
$per_page = 5;
 
// 파라미터
$search = NULL;
$query = NULL;
$page = $this->uri->segment(4);
// 검색 파라미터 세팅
if ($this->uri->segment(3) == 'search')
{
$search = $this->uri->segment(4);
$query = $this->uri->segment(6);
$page = $this->uri->segment(8);
}
 
// 데이터 로딩.
$result = $this->shop_model->lists2($search, base64_decode($query), $page, $per_page);
// 페이징.
$c>
'total_rows' => $result['total_count'],
'per_page' => $per_page,
'uri_segment' => $search != NULL ? 8 : 4,
'base_url' => '/shop/lists'.$this->uri->uri_string(3, 'page').'/page'
);
$this->load->library('pagination');
$this->pagination->initialize($config);
// 화면 데이터.
$data = array(
'total_count' => $result['total_count'],
'idx' => $result['total_count'] - $page,
'lists' => $result['lists'],
'search' => $search,
'query' => base64_decode($query),
'pagination' => $this->pagination->create_links()
);
$this->layout->view('shop/lists', $data);
}
-----------------------------------------------------------------------

모듈 소스
-----------------------------------------------------------------------
function lists2($search, $query, $page, $per_page = 10)
{
$this->db->start_cache();
$this->db->where('status', 'Y');
$this->db->from('shop');
switch ($search)
{
case 'title':
$this->db->like('title', $query);
break;
}
$this->db->stop_cache();
// 전체 카운트
$total_count = $this->db->count_all_results();
 
// 데이터 리스트.
$this->db->select('idx, title, amount, sale_cnt, sale_inc_cnt, status, reg_date, front_img, desc');
$this->db->order_by('reg_date', 'desc');
$this->db->limit($per_page, $page);
$lists = $this->db->get()->result_array();
$this->db->flush_cache();
// 결과 세팅.
$result = array(
'total_count' => $total_count,
'lists' => $lists
);
return $result;
}
-----------------------------------------------------------------------

에러주소 : reps.co.kr/shop/lists

태그 캐시,cache
 다음글 자바스크립트를 컨트롤러로... (2)
 이전글 mysql 파일 덤프 (3)

댓글

변종원(웅파) / 2014/01/12 14:06:12 / 추천 0
캐시기능 자체를 끄고 테스트해보세요.

그리고 $this->db->cache_delete() 함수로 해당 페이지의 쿼리만 삭제해보시구요.

포럼 소스 다운 받아서 cache_ 로 검색해보세요.

메인 페이지에 캐시가 적용되어 있습니다. 글을 쓰거나 수정, 삭제를 하면 메인 캐시를 비우도록
작업되어 있습니다.
솔해 / 2014/01/13 00:54:52 / 추천 0
 답변 감사합니다.

포럼소스로 해결했네요. 

행복한날 되시길...^^;