Try to cache vacation for each account to avoid to connect to IMAP server if vacation rules are not changed

This commit is contained in:
Hadi Nategh 2014-08-06 10:56:01 +00:00
parent 70d85ca78f
commit 4830bcf784
2 changed files with 16 additions and 2 deletions

View File

@ -620,6 +620,8 @@ class mail_sieve
{ {
self::setAsyncJob($newVacation); self::setAsyncJob($newVacation);
} }
//Reset vacationNotice cache which is used in mail_ui get_rows
egw_cache::unsetCache(egw_cache::INSTANCE,'email', 'vacationNotice'+$icServer->acc_id);
$msg = lang('Vacation notice sucessfully updated.'); $msg = lang('Vacation notice sucessfully updated.');
} }
} }

View File

@ -2295,9 +2295,21 @@ class mail_ui
{ {
$sieveServer = $this->mail_bo->icServer; $sieveServer = $this->mail_bo->icServer;
try try
{
//Get vacation from cache if it's available
$vacationCached = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'vacationNotice'+$sieveServer->acc_id);
if (!$vacationCached)
{ {
$sieveServer->retrieveRules(); $sieveServer->retrieveRules();
$vacation = $sieveServer->getVacation(); $vacation = $sieveServer->getVacation();
// Set vacation to the instance cache for particular account
egw_cache::setCache(egw_cache::INSTANCE, 'email', 'vacationNotice'+$sieveServer->acc_id, $vacation);
}
else
{
return $vacationCached;
}
} catch (PEAR_Exception $ex) { } catch (PEAR_Exception $ex) {
$this->callWizard($ex->getMessage()); $this->callWizard($ex->getMessage());
} }