-
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
[FEATURE] Add support for multiple cache implementations, separating result, query and metadata caching. #205
Conversation
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.
Can you also update the config file with the new structure, thanks!
It would be good to provide env variables for the 3 drivers as well. They can all 3 default to the DOCTRINE_CACHE env variable.
| $this->setSecondLevelCaching($configuration); | ||
| } | ||
|
|
||
| private function applyNamedCacheConfiguration($cacheName) |
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.
Docblocks
src/EntityManagerFactory.php
Outdated
| $defaultDriver = $this->config->get('doctrine.cache.default', $this->defaultCache['type']); | ||
| $defaultNamespace = $this->config->get('doctrine.cache.namespace', $this->defaultCache['namespace']); | ||
|
|
||
| $driverType = $this->config->get('doctrine.cache.' . $cacheName . '.type', $defaultDriver); |
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.
type should be named driver
…rs and second level caching
Also added some docblock comments
1193e9e to
74bb417
Compare
|
I added the requested changes... I also rebased from 1.2 to keep my branch up to date. I'd already made the changes before I saw the DOCTRINE_CACHE env variable comment. I made them take on new env variables. Do you want me to change that? |
| 'second_level' => false, | ||
| 'cache' => [ | ||
| 'second_level' => false, | ||
| 'default' => 'array', |
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'),
| $defaultDriver = $this->config->get('doctrine.cache.default', $this->defaultCache['type']); | ||
| $defaultNamespace = $this->config->get('doctrine.cache.namespace', $this->defaultCache['namespace']); | ||
|
|
||
| $driver = $this->config->get('doctrine.cache.' . $cacheName . '.driver', $defaultDriver); |
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.
$cache = $this->cache->driver($driver);
if ($namespace = $this->config->get('doctrine.cache.' . $cacheName . '.namespace', $defaultNamespace)) {
$cache->setNamespace($namespace);
}
return $cache;| */ | ||
| private function applyNamedCacheConfiguration($cacheName) | ||
| { | ||
| $defaultDriver = $this->config->get('doctrine.cache.default', $this->defaultCache['type']); |
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.
Replace $this->defaultCache['type'] by 'array'
Remove $this->defaultCache['namespace']
|
|
||
| /** | ||
| * @var array | ||
| */ |
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.
Not necessary
No it's fine. |
If you have memcached or redis extensions installed doctrine will try to automatically connect to one of them if no cache paramter is set when dev mode is off. Defaulting to the default driver to prevent that behavior from occuring. Signed-off-by: RJ Garcia <rj@bighead.net>
If you have memcached or redis extensions installed doctrine will try to automatically connect to one of them if no cache paramter is set when dev mode is off. Defaulting to the default driver to prevent that behavior from occuring. Signed-off-by: RJ Garcia <rj@bighead.net>
This PR adds the ability to configure a different cache driver for each of metadata, result and query caching through the
doctrine.phpconfig file'cache'array.Changes proposed in this pull request:
The current cache array format is as follows:
This branch introduces this format:
The configuration is currently applied in this PR by calling
\Doctrine\ORM\Configuration->set[Result|Query|Metadata]CacheImplafter reading the values from the config.The
defaultcache array entries remain the same to ensure backwards compatibility. If any of the metadata, result or query entries are missing from the configuration then they will take whichever the default entry is. The default entry is also mirrored/stored directly in code in case it's accidentally deleted from the configuration.