BUG 0000 adding memcache to processList

fixing telefonica slow issues
This commit is contained in:
Fernando Ontiveros
2012-04-12 17:33:16 -04:00
parent 925e6e8881
commit 84dbad7617
3 changed files with 59 additions and 30 deletions

View File

@@ -29,22 +29,46 @@ $start = isset($_POST['start'])? $_POST['start']: 0;
$limit = isset($_POST['limit'])? $_POST['limit']: '';
$oProcess = new Process();
if( isset($_POST['category']) && $_POST['category'] !== '<reset>' ){
if( isset($_POST['processName']) )
$proData = $oProcess->getAllProcesses($start, $limit, $_POST['category'], $_POST['processName']);
else
$proData = $oProcess->getAllProcesses($start, $limit, $_POST['category']);
}
else {
if( isset($_POST['processName']) )
$proData = $oProcess->getAllProcesses($start, $limit, null, $_POST['processName']);
else
$proData = $oProcess->getAllProcesses($start, $limit);
}
$r->data = $proData;
$memcache = & PMmemcached::getSingleton(SYS_SYS);
$memkey = 'no memcache';
$memcacheUsed = 'not used';
$totalCount = 0;
//$r->totalCount = count($proData);
$r->totalCount = $oProcess->getAllProcessesCount();
if( isset($_POST['category']) && $_POST['category'] !== '<reset>' ) {
if( isset($_POST['processName']) )
$proData = $oProcess->getAllProcesses($start, $limit, $_POST['category'], $_POST['processName']);
else
$proData = $oProcess->getAllProcesses($start, $limit, $_POST['category']);
}
else {
if( isset($_POST['processName']) ) {
$memkey = 'processList-' . $start . '-' . $limit . '-' . $_POST['processName'];
$memcacheUsed = 'yes';
if ( ($proData = $memcache->get( $memkey )) === false ) {
$proData = $oProcess->getAllProcesses($start, $limit, null, $_POST['processName']);
$memcache->set( $memkey , $proData, PMmemcached::ONE_HOUR );
$memcacheUsed = 'no';
}
}
else {
$memkey = 'processList-allProcesses-' . $start . '-' . $limit;
$memkeyTotal = $memkey . '-total';
$memcacheUsed = 'yes';
if ( ($proData = $memcache->get( $memkey )) === false || ($totalCount=$memcache->get( $memkeyTotal)) === false ) {
$proData = $oProcess->getAllProcesses($start, $limit);
$totalCount = $oProcess->getAllProcessesCount();
$memcache->set( $memkey , $proData, PMmemcached::ONE_HOUR );
$memcache->set( $memkeyTotal , $totalCount, PMmemcached::ONE_HOUR );
$memcacheUsed = 'no';
}
}
}
$r->memkey = $memkey;
$r->memcache = $memcacheUsed;
$r->data = $proData;
$r->totalCount = $totalCount;
echo G::json_encode($r);
echo G::json_encode($r);