Issue #0001653: Caching WorldCheck searchlist and content data
This commit is contained in:
parent
0560448501
commit
0dad63915a
@ -45,14 +45,33 @@ class WorldcheckController extends Zend_Controller_Action
|
||||
$summary->nameIdentifier = $nameIdentifier;
|
||||
$summary->matchType = 'WATCHLIST';
|
||||
|
||||
//get results by lastName
|
||||
$unfilteredWC = new stdClass();
|
||||
$unfilteredWC = $wc->getSummariesArr($summary);
|
||||
$configWC = new Zend_Config_Ini(APPLICATION_PATH . '/../library/WorldCheck/applicationWC.ini');
|
||||
$wcConfig = $configWC->worldcheck->toArray();
|
||||
|
||||
//caching
|
||||
$cache_dir = $wcConfig['cachedir']['path'].$wcConfig['cachedir']['name'];
|
||||
if (!is_dir($cache_dir)) mkdir($cache_dir, 0777, true);
|
||||
|
||||
$frontendOptions = array(
|
||||
'lifetime' => $wcConfig['cachedir']['lifetime'],
|
||||
'automatic_serialization' => true
|
||||
);
|
||||
$backendOptions = array('cache_dir' => $cache_dir);
|
||||
$cache = Zend_Cache::factory('Output','File',$frontendOptions,$backendOptions);
|
||||
|
||||
if(!($unfilteredWC = $cache->load($nameIdentifier))) {
|
||||
//get results by lastName
|
||||
$unfilteredWC = new stdClass();
|
||||
$unfilteredWC = $wc->getSummariesArr($summary);
|
||||
//end
|
||||
$cache->save($unfilteredWC, $nameIdentifier);
|
||||
}
|
||||
//end
|
||||
|
||||
//check if display all results (search by lastName), or filtered results (search by fullName)
|
||||
$filtre = $request->getParam('filtre', 'tout');
|
||||
$resultWC = $unfilteredWC;
|
||||
Zend_Registry::get('firebug')->info($resultWC);
|
||||
if ($filtre=='filtered')
|
||||
{
|
||||
//get results by fullName (lastName and givenName)
|
||||
@ -87,29 +106,14 @@ class WorldcheckController extends Zend_Controller_Action
|
||||
$this->view->assign('filtres', $filtres);
|
||||
//end
|
||||
|
||||
$configWC = new Zend_Config_Ini(APPLICATION_PATH . '/../library/WorldCheck/applicationWC.ini');
|
||||
$cacheConfig = $configWC->worldcheck->toArray();
|
||||
|
||||
|
||||
/*$frontendOptions = array(
|
||||
'lifetime' => $cacheConfig['cachedir']['lifetime'],
|
||||
'automatic_serialization' => true
|
||||
);
|
||||
$backendOptions = array('cache_dir' => $cacheConfig['cachedir']['path'].$cacheConfig['cachedir']['name']);
|
||||
$cache = Zend_Cache::factory('Output','File',$frontendOptions,$backendOptions);*/
|
||||
|
||||
//paginate results list
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('worldcheck/controls.phtml');
|
||||
$paginator = Zend_Paginator::factory($resultWC);
|
||||
$this->view->paginator = $paginator;
|
||||
$itemCount = $cacheConfig['page']['items'];
|
||||
$itemCount = $wcConfig['page']['items'];
|
||||
$page = $this->_getParam('page', 1);
|
||||
$ol_number = ($page-1)*$itemCount+1;
|
||||
|
||||
/*if(!($cache->load('page_'.$page))) {
|
||||
$cache->save($paginator, 'page_'.$page);
|
||||
}*/
|
||||
|
||||
$paginator->setCurrentPageNumber($page);
|
||||
$paginator->setItemCountPerPage($itemCount);
|
||||
|
||||
@ -157,7 +161,26 @@ class WorldcheckController extends Zend_Controller_Action
|
||||
$param->nameType = $session->getNameType();
|
||||
|
||||
$wc = new WsWorldCheck();
|
||||
$content = $wc->getDetailsContent($param);
|
||||
|
||||
// using zend_cache for matchContent
|
||||
$configWC = new Zend_Config_Ini(APPLICATION_PATH . '/../library/WorldCheck/applicationWC.ini');
|
||||
$cacheConfig = $configWC->worldcheck->toArray();
|
||||
|
||||
$frontendOptions = array(
|
||||
'lifetime' => $cacheConfig['cachedir']['lifetime'],
|
||||
'automatic_serialization' => true
|
||||
);
|
||||
$backendOptions = array(
|
||||
'cache_dir' => $cacheConfig['cachedir']['path'].$cacheConfig['cachedir']['name']
|
||||
);
|
||||
|
||||
$cache = Zend_Cache::factory('Output','File',$frontendOptions,$backendOptions);
|
||||
|
||||
if(!($content = $cache->load($param->matchIdentifier)))
|
||||
{
|
||||
$content = $wc->getDetailsContent($param);
|
||||
$cache->save($content, $param->matchIdentifier);
|
||||
}
|
||||
|
||||
$this->view->assign('matchIdentifier', $param->matchIdentifier);
|
||||
$this->view->assign('content', $content);
|
||||
|
@ -10,4 +10,4 @@ wsworldcheck.response.start = 0
|
||||
worldcheck.page.items = 15
|
||||
worldcheck.cachedir.path = ../data/cache/
|
||||
worldcheck.cachedir.name = worldcheck
|
||||
worldcheck.cachedir.lifetime = 7200
|
||||
worldcheck.cachedir.lifetime = 86400
|
Loading…
Reference in New Issue
Block a user