Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[FrameworkBundle] Add cache adapters in semantic configuration #18625

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 1 commit into from

Conversation

tgalopin
Copy link
Contributor

@tgalopin tgalopin commented Apr 23, 2016

Q A
Branch? 3.1
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

Following other PRs about the integration of the Cache component into the FrameworkBundle, this PR proposes the possibility to define and overide adapters from the semantic configuration.

There are three main reasons why I think we should be able to configure adapters from the config_*.yml files:

  • to be consistent with cache pools
  • because it's very useful to be able to override local/shared adapters dependeing on the environment
  • because it's easier to understand the Cache components concepts in simple YAML configuration than with services (currently, to override adapters, we need to define services).

Here is an example of how we could configure every shared cache of the application to use redis instead of the filesystem with this proposal:

framework:    
    cache:
        adapters:
            shared:
                parent:               cache.adapter.redis
                provider:             app.redis_connection

By default, the FrameworkBundle defines some useful adapters and pools. Using this proposal configuration, we can represent these adapters and pools like these:

framework:
    #...

    cache:
        adapters:
            apcu:
                parent:               ~
                default_lifetime:     ~
                provider:             ~
            doctrine:
                parent:               ~
                default_lifetime:     ~
                provider:             ~
            filesystem:
                parent:               ~
                default_lifetime:     ~
                provider:             ~
            psr6:
                parent:               ~
                default_lifetime:     ~
                provider:             ~
            redis:
                parent:               ~
                default_lifetime:     ~
                provider:             ~
            local:
                parent:               cache.adapter.filesystem
                default_lifetime:     ~
                provider:             ~
            shared:
                parent:               cache.adapter.filesystem
                default_lifetime:     ~
                provider:             ~
        pools:
            validator:
                adapter:              cache.adapter.local
                public:               false
                default_lifetime:     ~
                provider:             ~
                namespace:            ~
                clearer:              cache.default_pools_clearer
            serializer:
                adapter:              cache.adapter.local
                public:               false
                default_lifetime:     ~
                provider:             ~
                namespace:            ~
                clearer:              cache.default_pools_clearer
            app:
                adapter:              cache.adapter.shared
                public:               false
                default_lifetime:     ~
                provider:             ~
                namespace:            ~
                clearer:              cache.default_pools_clearer

And every adapter could be overriden by using the key parent or by using the same name as the parent adapter (if you redefine the redis adapter to use a different provider, it will override the parent definition).

This PR also removes the local and shared pool for a single app pool. This is done to avoid confusion for users between the local/shared adapters and the local/shared pools and because app cache will almost always be shared.

@tgalopin tgalopin changed the title [WIP][Cache][FrameworkBundle] Add cache adapters in semantic configuration [RFC][Cache][FrameworkBundle] Add cache adapters in semantic configuration Apr 23, 2016
</service>

<service id="cache.pool.local" parent="cache.adapter.local">
<service id="cache.pool.app" parent="cache.adapter.shared">
Copy link
Member

Choose a reason for hiding this comment

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

@javiereguiluz WDYT about this one? We'd like to provide a preconfigured cache pool for user's need, so that one can inject it without much configuration. Currently we have two of these (cache.pool.local and cache.pool.shared).
The proposal here is to remove cache.pool.local and rename cache.pool.shared to cache.pool.app.
Which means we have to questions:

  • OK for removing the local pool and keep only the shared one?
  • is the cache.pool.app name OK or do we have a better idea (e.g. is cache.pool.user better)?

Copy link
Member

Choose a reason for hiding this comment

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

At first glance, maybe this should be called cache.pool.default I don't like the .app suffix because all the pools are for the app and because the app. convention is commonly used as a prefix for user's stuff.

Copy link
Member

Choose a reason for hiding this comment

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

But the pool we're talking about is only for user's stuff :)

@nicolas-grekas
Copy link
Member

👍 with a few more tests, must be on 3.1 or will be much harder to change afterwards.

@nicolas-grekas nicolas-grekas changed the title [RFC][Cache][FrameworkBundle] Add cache adapters in semantic configuration [Cache][FrameworkBundle] Add cache adapters in semantic configuration Apr 25, 2016
@nicolas-grekas nicolas-grekas changed the title [Cache][FrameworkBundle] Add cache adapters in semantic configuration [FrameworkBundle] Add cache adapters in semantic configuration Apr 25, 2016
@xabbuh
Copy link
Member

xabbuh commented Apr 25, 2016

We need to update the XML schema definition.

@@ -58,5 +39,20 @@
<argument /> <!-- default lifetime -->
</service>

<service id="cache.adapter.shared" alias="cache.adapter.filesystem" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put the adapters here to follow the reading order (as in the configuration, the extension, etc.)

@tgalopin tgalopin force-pushed the cache-config branch 3 times, most recently from 00986d1 to 959bf64 Compare April 27, 2016 19:08
@nicolas-grekas
Copy link
Member

Included in #18667
Thank you @tgalopin for working on this!

@tgalopin tgalopin deleted the cache-config branch April 28, 2016 19:26
fabpot added a commit that referenced this pull request May 4, 2016
…caches (tgalopin, nicolas-grekas)

This PR was merged into the 3.1-dev branch.

Discussion
----------

[FrameworkBundle] Semantic config for app/system/pool caches

| Q             | A
| ------------- | ---
| Branch?       | 3.1
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #18625
| License       | MIT
| Doc PR        | -

Commits
-------

a2a567d [FrameworkBundle] Simplify config for app/system/pool caches
80a5508 [FrameworkBundle] Add cache adapters in semantic configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.