try to improve performance (main target here is esync) by using instance cache instead of sessionCache for folderObjects and deletedMessages

This commit is contained in:
Klaus Leithoff 2012-05-31 09:17:35 +00:00
parent 0349f92b56
commit f87891bb1d
4 changed files with 26 additions and 18 deletions

View File

@ -601,9 +601,19 @@ class emailadmin_bo extends so_sql
unset($structure[$_profileID]);
egw_cache::setCache(egw_cache::INSTANCE,'email','structureCache'.trim($GLOBALS['egw_info']['user']['account_id']),$structure, $expiration=60*60*1);
}
//reset cache, to trigger reload
$folders2return =& egw_cache::getSession('felamimail','folderObjects');
if (isset($folders2return[$_profileID])) unset($folders2return[$_profileID]);
//reset folderObject cache, to trigger reload
$folders2return = egw_cache::getCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
if (isset($folders2return[$_profileID]))
{
unset($folders2return[$_profileID]);
egw_cache::setCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return, $expiration=60*60*1);
}
$eMailListContainsDeletedMessages = egw_cache::getCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
if (isset($eMailListContainsDeletedMessages[$_profileID]))
{
unset($eMailListContainsDeletedMessages[$_profileID]);
egw_cache::setCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, $expiration=60*60*1);
}
$nameSpace = egw_cache::getSession('email','defaultimap_nameSpace');
if (isset($nameSpace[$_profileID]))

View File

@ -102,9 +102,6 @@ class ajaxfelamimail
$newSubFolder = $this->_encodeDisplayFolderName($newSubFolder);
$response->addScript("tree.insertNewItem('$parentFolder','$folderName','$newSubFolder',onNodeSelect,'folderClosed.gif',0,0,'CHILD,CHECKED');");
}
//reset cache, to trigger reload
$folders2return =& egw_cache::getSession('felamimail','folderObjects');
if (isset($folders2return[$this->bofelamimail->icServer->ImapServerId])) unset($folders2return[$this->bofelamimail->icServer->ImapServerId]);
//reset Form
$response->addAssign("newSubFolder", "value", '');
@ -429,9 +426,6 @@ class ajaxfelamimail
$folderName = $this->_encodeFolderName($folderName);
$response->addScript("tree.deleteItem('$folderName',1);");
}
//reset cache, to trigger reload
$folders2return =& egw_cache::getSession('felamimail','folderObjects');
if (isset($folders2return[$this->bofelamimail->icServer->ImapServerId])) unset($folders2return[$this->bofelamimail->icServer->ImapServerId]);
return $response->getXML();
}
@ -1321,9 +1315,6 @@ class ajaxfelamimail
$response->addScript("window.tree.insertNewItem('$_parentFolder','$newFolderName','$folderName',onNodeSelect,'MailFolderPlain.png',0,0,'CHILD,CHECKED,SELECT,CALL');");
}
}
//reset cache, to trigger reload
$folders2return =& egw_cache::getSession('felamimail','folderObjects');
if (isset($folders2return[$this->bofelamimail->icServer->ImapServerId])) unset($folders2return[$this->bofelamimail->icServer->ImapServerId]);
return $response->getXML();
}
@ -1598,9 +1589,6 @@ class ajaxfelamimail
$status = (bool)$_status;
$this->bofelamimail->subscribe($folderName, $status);
//reset cache, to trigger reload
$folders2return =& egw_cache::getSession('felamimail','folderObjects');
if (isset($folders2return[$this->bofelamimail->icServer->ImapServerId])) unset($folders2return[$this->bofelamimail->icServer->ImapServerId]);
$response = new xajaxResponse();
return $response->getXML();

View File

@ -1627,7 +1627,7 @@ class felamimail_bo
static $folders2return;
if ($_subscribedOnly && $_getCounters===false)
{
if (is_null($folders2return)) $folders2return =& egw_cache::getSession('felamimail','folderObjects');
if (is_null($folders2return)) $folders2return = egw_cache::getCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
if (isset($folders2return[$this->icServer->ImapServerId]))
{
//error_log(__METHOD__.__LINE__.' using Cached folderObjects');
@ -1951,6 +1951,7 @@ class felamimail_bo
//$folders2return = array_merge($autoFolderObjects,$folders);
//_debug_array($folders2return); #exit;
$folders2return[$this->icServer->ImapServerId] = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders);
if ($_subscribedOnly && $_getCounters===false) egw_cache::setCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1);
return $folders2return[$this->icServer->ImapServerId];
}
@ -2332,7 +2333,7 @@ class felamimail_bo
//error_log(__METHOD__.__LINE__.' Filter:'.array2string($_filter));
$try2useCache = true;
static $eMailListContainsDeletedMessages;
if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages =& egw_cache::getSession('felamimail','email_eMailListContainsDeletedMessages');
if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = egw_cache::getCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
// this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED
if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false)))
{
@ -2341,6 +2342,7 @@ class felamimail_bo
$deletedMessages = $this->getSortedList($_folderName, 0, $three=1, array('status'=>array('DELETED')),$five=true,false);
//error_log(__METHOD__.__LINE__.array2string($deletedMessages));
$eMailListContainsDeletedMessages[$this->profileID][$_folderName] = count($deletedMessages);
egw_cache::setCache(egw_cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, $expiration=60*60*1);
//$endtime = microtime(true);
//$r = ($endtime-$starttime);
//error_log(__METHOD__.__LINE__.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['EXISTS']).'/'.$this->sessionData['folderStatus'][$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.$this->sessionData['folderStatus'][$this->profileID][$_folderName]['deleted']);
@ -2357,7 +2359,7 @@ class felamimail_bo
//$this->sessionData['folderStatus'][0][$_folderName]['reverse'] === $_reverse &&
!empty($this->sessionData['folderStatus'][$this->profileID][$_folderName]['sortResult']))
) {
if (self::$debug) error_log(__METHOD__." USE CACHE for Profile:". $this->profileID." Folder:".$_folderName.'->'.($setSession?'setSession':'checkrun'));
if (self::$debug) error_log(__METHOD__." USE CACHE for Profile:". $this->profileID." Folder:".$_folderName.'->'.($setSession?'setSession':'checkrun').function_backtrace());
$sortResult = $this->sessionData['folderStatus'][$this->profileID][$_folderName]['sortResult'];
} else {

View File

@ -448,6 +448,14 @@
if(!(empty($preferences->preferences['prefpreventmanagefolders']) || $preferences->preferences['prefpreventmanagefolders'] == 0)) {
die('you are not allowed to be here');
}
//reset folderObject cache, to trigger reload
$folders2return = egw_cache::getCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
if (isset($folders2return[$this->bofelamimail->icServer->ImapServerId]))
{
unset($folders2return[$this->bofelamimail->icServer->ImapServerId]);
egw_cache::setCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return, $expiration=60*60*1);
}
// rename a mailbox
if(isset($_POST['newMailboxName']))
{