2011-12-16 3 views
2

젠드 프레임 워크 & Doctrine 2 및 DoctrineExtensions 페이지 번호 어댑터와 함께 Zend_Paginator를 사용하고 있습니다.어떻게 페이지 매김 결과와 교리를 캐시합니까?

내 결과를 캐시해야하지만 어디에서해야합니까?

내가 저장소에서 수행하는 것이 논리적 인 것처럼 보였지만 시도했으나 페이징 어댑터로는 작동하지 않습니다.

어떨까요?

답변

0

체크 아웃 Zend_Cache 이 파일, 데이터베이스, memcached를 포함한 다양한 어댑터의 소수입니다 -하지만 그것을 처리하는 일반적인 방법은 이것이다 :

$frontendOptions = array(
    'lifetime' => 7200, // cache lifetime of 2 hours 
    'automatic_serialization' => true 
); 

$backendOptions = array(
    'cache_dir' => './tmp/' // Directory where to put the cache files 
); 

// getting a Zend_Cache_Core object 
$cache = Zend_Cache::factory('Core', 
          'File', 
          $frontendOptions, 
          $backendOptions); 

if(($result = $cache->load('myresult')) === false) { 
    // fetch $result 
    $cache->save($result, 'myresult'); 
} 

$result가 캐시 VAR 없습니다.

+0

안녕하세요, 나는 Doctrine 또는 Paginator 인스턴스에서 PDO 인스턴스를 직접 래핑 할 수 없으므로 작동합니다. – Trent