Merge pull request #554 from owncloud/server-side-caching

configurable option to enable server side caching
This commit is contained in:
Thomas Müller 2015-05-03 23:45:20 +02:00
Родитель 14f165d11b 355e22ab88
Коммит a7b46ad7a3
2 изменённых файлов: 28 добавлений и 2 удалений

Просмотреть файл

@ -46,10 +46,20 @@ Go to ownCloud Mail in the browser and run this from the developer console to cl
localStorage.clear();
```
Configuration
-------------
Certain advanced or experimental features need specific enablement in config.php:
### Debug mode
You can enable IMAP backend logging. Add this to your config.php:
You can enable IMAP backend logging. A horde.log will appear in the same directory as your owncloud.log.
```php
'app.mail.imaplog.enabled' => true
```
A horde.log will appear in the same directory as your owncloud.log.
### Server-side caching
Mailbox messages and accounts can be cached on the ownCloud server to reduce mail server load:
This requires a valid memcache to be configured
```php
'app.mail.server-side-cache.enabled' => true
```

Просмотреть файл

@ -15,8 +15,10 @@ use Horde_Imap_Client_Mailbox;
use Horde_Imap_Client_Socket;
use Horde_Imap_Client;
use Horde_Mail_Transport_Smtphorde;
use OCA\Mail\Cache\Cache;
use OCA\Mail\Db\MailAccount;
use OCP\IConfig;
use OCP\ICacheFactory;
class Account {
@ -38,6 +40,9 @@ class Account {
/** @var IConfig */
private $config;
/** @var ICacheFactory */
private $memcacheFactory;
/**
* @param MailAccount $account
*/
@ -46,6 +51,7 @@ class Account {
$this->mailboxes = null;
$this->crypto = \OC::$server->getCrypto();
$this->config = \OC::$server->getConfig();
$this->memcacheFactory = \OC::$server->getMemcacheFactory();
}
/**
@ -92,6 +98,16 @@ class Account {
if ($this->config->getSystemValue('app.mail.imaplog.enabled', false)) {
$params['debug'] = $this->config->getSystemValue('datadirectory') . '/horde.log';
}
if ($this->config->getSystemValue('app.mail.server-side-cache.enabled', false)) {
if ($this->memcacheFactory->isAvailable()) {
$params['cache'] = [
'backend' => new Cache(array(
'cacheob' => $this->memcacheFactory
->create(md5($this->getId() . $this->getEMailAddress()))
))];
}
}
$this->client = new \Horde_Imap_Client_Socket($params);
$this->client->login();
}