Skip to content

[Config][FrameworkBundle/Translation][Router] Interchangeable ConfigCache #5912

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

Closed
wants to merge 9 commits into from
Closed

[Config][FrameworkBundle/Translation][Router] Interchangeable ConfigCache #5912

wants to merge 9 commits into from

Conversation

bnw
Copy link

@bnw bnw commented Nov 5, 2012

We would like to use a custom implementation of ConfigCache to employ a modified caching strategy. Basically, it is about special kinds of resources that might change on runtime also during production (will post more details if anyone is interested).

Currently the ConfigCache implementation is not exchangeable, which this what this PR addresses. I have tried to keep BC as far as possible. If that is not a hard requirement, I could also come up with different implementations.

Alternatively, a factory method for the ConfigCache in client classes could do.

Additionally, the kernel uses ConfigCache for the service container itself. We did not touch that part because there is probably no useful way to configure or inject alternative implementations before the container itself is available.

Q A
Bug fix? no
New feature? yes (refactoring and added flex point)
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR none

private function getConfigCacheFactory()
{
if (!$this->configCacheFactory) {
$this->configCacheFactory = new \Symfony\Component\Config\ConfigCacheFactory($this->options['debug']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this as a use above and refer to the alias.

@mpdude
Copy link
Contributor

mpdude commented Jan 25, 2013

Made some fixes, let's wait for the next Travis build

@mpdude
Copy link
Contributor

mpdude commented Jan 26, 2013

The problem with tests is that now the service "translator.default" has a dependency on a non-existent service "config.config_cache_factory".

@@ -70,6 +71,9 @@
</argument>
<argument type="service" id="router.request_context" on-invalid="ignore" />
<argument type="service" id="logger" on-invalid="ignore" />
<call method="setConfigCacheFactory">
<argument type="service" id="config.config_cache_factory" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong service id here

…ory altogether, as Router and Translator will still fall back to old behaviour (BC).
@mpdude
Copy link
Contributor

mpdude commented Jan 26, 2013

I removed all the new service definitions as all code will by default behave as before (creating default implementations).

Only clients that want to change the factory implementation need to inject the right (new) one and can do so in a compiler pass.

It is a common pattern for clients of ConfigCache/ConfigCacheFactory to check whether the cache is fresh and if not, fill it. This removes a little bit of repeated code.
Additionally, it gives factory implementations more control over how the cache is written to (for example they can employ other file locking/atomic write strategies).
@mpdude
Copy link
Contributor

mpdude commented Feb 15, 2013

@fabpot Do you think this PR is a worthwhile improvement that has any chance of being merged at all?

Otherwise we'd need to find other ways to solve the problem in our projects.

@fabpot
Copy link
Member

fabpot commented Apr 20, 2013

Closing for the most recent work on this topic in #7230

@fabpot fabpot closed this Apr 20, 2013
@mpdude mpdude deleted the replaceable-configCache3 branch September 24, 2015 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants