Add Doctrine cache configuration
[MAILPOET-2014]
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace MailPoet\Doctrine;
|
namespace MailPoet\Doctrine;
|
||||||
|
|
||||||
|
use MailPoet\Config\Env;
|
||||||
use MailPoetVendor\Doctrine\Common\Annotations\SimpleAnnotationReader;
|
use MailPoetVendor\Doctrine\Common\Annotations\SimpleAnnotationReader;
|
||||||
|
use MailPoetVendor\Doctrine\Common\Cache\ArrayCache;
|
||||||
use MailPoetVendor\Doctrine\Common\Cache\FilesystemCache;
|
use MailPoetVendor\Doctrine\Common\Cache\FilesystemCache;
|
||||||
use MailPoetVendor\Doctrine\Common\Proxy\AbstractProxyFactory;
|
use MailPoetVendor\Doctrine\Common\Proxy\AbstractProxyFactory;
|
||||||
use MailPoetVendor\Doctrine\ORM\Configuration;
|
use MailPoetVendor\Doctrine\ORM\Configuration;
|
||||||
@@ -27,6 +29,7 @@ class ConfigurationFactory {
|
|||||||
|
|
||||||
$this->configureMetadata($configuration);
|
$this->configureMetadata($configuration);
|
||||||
$this->configureProxies($configuration);
|
$this->configureProxies($configuration);
|
||||||
|
$this->configureCache($configuration);
|
||||||
|
|
||||||
if (!$this->is_dev_mode) {
|
if (!$this->is_dev_mode) {
|
||||||
$configuration->ensureProductionSettings();
|
$configuration->ensureProductionSettings();
|
||||||
@@ -55,4 +58,17 @@ class ConfigurationFactory {
|
|||||||
: AbstractProxyFactory::AUTOGENERATE_NEVER
|
: AbstractProxyFactory::AUTOGENERATE_NEVER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function configureCache(Configuration $configuration) {
|
||||||
|
if ($this->is_dev_mode) {
|
||||||
|
$cache = new ArrayCache();
|
||||||
|
} else {
|
||||||
|
$cache_dir = Env::$cache_path . '/doctrine';
|
||||||
|
$cache = new FilesystemCache($cache_dir);
|
||||||
|
$cache->setNamespace('mp3-' . md5($cache_dir) . '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
$configuration->setQueryCacheImpl($cache);
|
||||||
|
$configuration->setResultCacheImpl($cache);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user