-
Notifications
You must be signed in to change notification settings - Fork 179
[FEATURE] Add support for multiple cache implementations, separating result, query and metadata caching. #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
634a300
c93a9f4
94edfab
26334ff
3cb3d4f
e8a2f16
617b0a5
2d8e784
74bb417
7cf795b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,14 @@ class EntityManagerFactory | |
| */ | ||
| private $resolver; | ||
|
|
||
| /** | ||
| * @var array | ||
| */ | ||
| private $defaultCache = [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessary |
||
| 'type' => 'array', | ||
| 'namespace' => null | ||
| ]; | ||
|
|
||
| /** | ||
| * @param Container $container | ||
| * @param Setup $setup | ||
|
|
@@ -93,8 +101,7 @@ public function create(array $settings = []) | |
| { | ||
| $configuration = $this->setup->createConfiguration( | ||
| array_get($settings, 'dev', false), | ||
| array_get($settings, 'proxies.path'), | ||
| $this->cache->driver() | ||
| array_get($settings, 'proxies.path') | ||
| ); | ||
|
|
||
| $this->setMetadataDriver($settings, $configuration); | ||
|
|
@@ -318,13 +325,31 @@ protected function setCustomFunctions(Configuration $configuration) | |
| */ | ||
| protected function setCacheSettings(Configuration $configuration) | ||
| { | ||
| if ($namespace = $this->config->get('doctrine.cache.namespace', null)) { | ||
| $this->cache->driver()->setNamespace($namespace); | ||
| } | ||
| $configuration->setQueryCacheImpl($this->applyNamedCacheConfiguration('query')); | ||
| $configuration->setResultCacheImpl($this->applyNamedCacheConfiguration('result')); | ||
| $configuration->setMetadataCacheImpl($this->applyNamedCacheConfiguration('metadata')); | ||
|
|
||
| $this->setSecondLevelCaching($configuration); | ||
| } | ||
|
|
||
| /** | ||
| * @param string $cacheName | ||
| * @return mixed | ||
| */ | ||
| private function applyNamedCacheConfiguration($cacheName) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docblocks |
||
| { | ||
| $defaultDriver = $this->config->get('doctrine.cache.default', $this->defaultCache['type']); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace |
||
| $defaultNamespace = $this->config->get('doctrine.cache.namespace', $this->defaultCache['namespace']); | ||
|
|
||
| $driver = $this->config->get('doctrine.cache.' . $cacheName . '.driver', $defaultDriver); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $cache = $this->cache->driver($driver);
if ($namespace = $this->config->get('doctrine.cache.' . $cacheName . '.namespace', $defaultNamespace)) {
$cache->setNamespace($namespace);
}
return $cache; |
||
|
|
||
| if ($namespace = $this->config->get('doctrine.cache.' . $cacheName . '.namespace', $defaultNamespace)) { | ||
| $this->cache->driver($driver)->setNamespace($namespace); | ||
| } | ||
|
|
||
| return $this->cache->driver($driver); | ||
| } | ||
|
|
||
| /** | ||
| * @param Configuration $configuration | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'default' => env('DOCTRINE_CACHE', 'array'),