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

@@ -1341,7 +1341,7 @@ class Criterion {
} catch (Exception $e) {
// we are only doing this to allow easier debugging, so
// no need to throw up the exception, just make note of it.
Propel::log("Could not get a DBAdapter, generated sql may be wrong", Propel::LOG_ERR);
//Propel::log("Could not get a DBAdapter, generated sql may be wrong", Propel::LOG_ERR);
}
//init $this->realtable

View File

@@ -713,6 +713,9 @@ class Process extends BaseProcess {
GROUP BY PRO_UID, APP_STATUS*/
require_once 'classes/model/Application.php';
$memcache = & PMmemcached::getSingleton(SYS_SYS);
$memkey = 'getCasesCountInAllProcesses';
if ( ($aProcesses = $memcache->get( $memkey )) === false ) {
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(ApplicationPeer::PRO_UID);
$oCriteria->addSelectColumn(ApplicationPeer::APP_STATUS);
@@ -728,6 +731,8 @@ class Process extends BaseProcess {
$row = $oDataset->getRow();
$aProcesses[$row['PRO_UID']][$row['APP_STATUS']] = $row['CNT'];
}
$memcache->set( $memkey , $aProcesses, PMmemcached::ONE_HOUR );
}
return $aProcesses;
}

View File

@@ -30,21 +30,45 @@ $limit = isset($_POST['limit'])? $_POST['limit']: '';
$oProcess = new Process();
if( isset($_POST['category']) && $_POST['category'] !== '<reset>' ){
$memcache = & PMmemcached::getSingleton(SYS_SYS);
$memkey = 'no memcache';
$memcacheUsed = 'not used';
$totalCount = 0;
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']) )
}
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']);
else
$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);
}
$r->data = $proData;
$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;
//$r->totalCount = count($proData);
$r->totalCount = $oProcess->getAllProcessesCount();
echo G::json_encode($r);
echo G::json_encode($r);