Use only array cache in Doctrine at the moment

[MAILPOET-2014]
This commit is contained in:
Jan Jakeš
2019-07-24 10:51:37 +02:00
committed by M. Shull
parent aa13de72cc
commit 6ede84af1b
2 changed files with 5 additions and 19 deletions

View File

@ -2,10 +2,8 @@
namespace MailPoet\Doctrine;
use MailPoet\Config\Env;
use MailPoetVendor\Doctrine\Common\Annotations\SimpleAnnotationReader;
use MailPoetVendor\Doctrine\Common\Cache\ArrayCache;
use MailPoetVendor\Doctrine\Common\Cache\FilesystemCache;
use MailPoetVendor\Doctrine\Common\Proxy\AbstractProxyFactory;
use MailPoetVendor\Doctrine\ORM\Configuration;
use MailPoetVendor\Doctrine\ORM\Mapping\UnderscoreNamingStrategy;
@ -30,10 +28,6 @@ class ConfigurationFactory {
$this->configureMetadata($configuration);
$this->configureProxies($configuration);
$this->configureCache($configuration);
if (!$this->is_dev_mode) {
$configuration->ensureProductionSettings();
}
return $configuration;
}
@ -62,14 +56,7 @@ class ConfigurationFactory {
}
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);
}

View File

@ -6,7 +6,6 @@ use MailPoet\Doctrine\ConfigurationFactory;
use MailPoet\Doctrine\MetadataCache;
use MailPoet\Doctrine\TablePrefixMetadataFactory;
use MailPoetVendor\Doctrine\Common\Cache\ArrayCache;
use MailPoetVendor\Doctrine\Common\Cache\FilesystemCache;
use MailPoetVendor\Doctrine\Common\Proxy\AbstractProxyFactory;
use MailPoetVendor\Doctrine\ORM\Configuration;
use MailPoetVendor\Doctrine\ORM\Mapping\Driver\AnnotationDriver;
@ -25,6 +24,10 @@ class ConfigurationFactoryTest extends \MailPoetTest {
expect($configuration->getMetadataCacheImpl())->isInstanceOf(MetadataCache::class);
expect($configuration->getMetadataDriverImpl())->isInstanceOf(AnnotationDriver::class);
// cache
expect($configuration->getQueryCacheImpl())->isInstanceOf(ArrayCache::class);
expect($configuration->getResultCacheImpl())->isInstanceOf(ArrayCache::class);
// proxies
expect(realpath($configuration->getProxyDir()))->equals(realpath(__DIR__ . '/../../../generated/doctrine-proxies'));
expect($configuration->getProxyNamespace())->equals('MailPoetDoctrineProxies');
@ -34,15 +37,11 @@ class ConfigurationFactoryTest extends \MailPoetTest {
// dev mode
$configuration_factory = new ConfigurationFactory(true);
$configuration = $configuration_factory->createConfiguration();
expect($configuration->getQueryCacheImpl())->isInstanceOf(ArrayCache::class);
expect($configuration->getResultCacheImpl())->isInstanceOf(ArrayCache::class);
expect($configuration->getAutoGenerateProxyClasses())->equals(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS);
// production mode
$configuration_factory = new ConfigurationFactory(false);
$configuration = $configuration_factory->createConfiguration();
expect($configuration->getQueryCacheImpl())->isInstanceOf(FilesystemCache::class);
expect($configuration->getResultCacheImpl())->isInstanceOf(FilesystemCache::class);
expect($configuration->getAutoGenerateProxyClasses())->equals(AbstractProxyFactory::AUTOGENERATE_NEVER);
}
}