Skip to content

[FrameworkBundle] Add a doctrine cache service definition for validator mapping #14429

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

Merged
merged 1 commit into from
Jun 23, 2015

Conversation

jakzal
Copy link
Contributor

@jakzal jakzal commented Apr 21, 2015

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR symfony/symfony-docs#5409

Following #12975, this PR only registers a new service so it's possible to use the new doctrine based cache implementation instead of the deprecated one. To use it, the end user would need to configure it in his config.yml:

framework:
    validation:
        cache: validator.mapping.cache.doctrine.apc

In 3.0 we'll be able to replace the deprecated definition by aliasing validator.mapping.cache.apc to validator.mapping.cache.doctrine.apc.

I thought of automatic wrapping of services which implement doctrine interface, but decided it would be too magic.

I'm not convinced if APC is a good default anymore and hope for some discussion. I've used it as it's also used in serializer, and probably translation (see #13986). Since there's a built in opcache in more recent PHP versions, and apcu doesn't seem to be stable, there are better choices. Perhaps a better default would be a filesystem cache (not better performing, but it works anywhere).

@cordoval
Copy link
Contributor

is this lazyloaded? 👎 This imo should just be documented http://www.craftitonline.com/2015/04/telling-symfony-to-use-cached-validation-from-doctrine-cache-bundle-provider/

@jakzal
Copy link
Contributor Author

jakzal commented Apr 22, 2015

@cordoval documenting is not enough imho. We need to provide an upgrade path.

@dunglas
Copy link
Member

dunglas commented Jun 15, 2015

👍

@xabbuh
Copy link
Member

xabbuh commented Jun 16, 2015

👍 We should just add this to the docs after merging.

@fabpot
Copy link
Member

fabpot commented Jun 16, 2015

Can we have the doc PR before merging?

@xabbuh
Copy link
Member

xabbuh commented Jun 16, 2015

yes, we can (see symfony/symfony-docs#5409)

@jakzal
Copy link
Contributor Author

jakzal commented Jun 17, 2015

I'm not convinced if APC is a good default anymore and hope for some discussion.

Any feedback on this one?

@fabpot
Copy link
Member

fabpot commented Jun 17, 2015

👍 Does not hurt to have this extra service anyway. Having some other alternatives would be good as well but out of the scope of this PR.

@jakzal
Copy link
Contributor Author

jakzal commented Jun 22, 2015

Ok then. Let's merge :)

@fabpot
Copy link
Member

fabpot commented Jun 23, 2015

Thank you @jakzal.

@fabpot fabpot merged commit 0642911 into symfony:2.8 Jun 23, 2015
fabpot added a commit that referenced this pull request Jun 23, 2015
…ion for validator mapping (jakzal)

This PR was merged into the 2.8 branch.

Discussion
----------

[FrameworkBundle] Add a doctrine cache service definition for validator mapping

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | symfony/symfony-docs#5409

Following #12975, this PR only registers a new service so it's possible to use the new doctrine based cache implementation instead of the deprecated one. To use it, the end user would need to configure it in his `config.yml`:

```yaml
framework:
    validation:
        cache: validator.mapping.cache.doctrine.apc
```

In 3.0 we'll be able to replace the deprecated definition by aliasing `validator.mapping.cache.apc` to `validator.mapping.cache.doctrine.apc`.

I thought of automatic wrapping of services which implement doctrine interface, but decided it would be too magic.

I'm not convinced if APC is a good default anymore and hope for some discussion. I've used it as it's also used in serializer, and probably translation (see #13986). Since there's a built in opcache in more recent PHP versions, and apcu doesn't seem to be stable, there are better choices. Perhaps a better default would be a filesystem cache (not better performing, but it works anywhere).

Commits
-------

0642911 [FrameworkBundle] Add a doctrine cache service definition for validator mapping
@jakzal jakzal deleted the validator/mapping-doctrine-cache branch June 24, 2015 12:47
@stof
Copy link
Member

stof commented Jun 25, 2015

@jakzal I think we should also provide an easy way to configure a DoctrineCache wrapping an existing service. This would allow people to configure their cache service thanks to DoctrineCacheBundle (included by default in the SE as it is a dependency of DoctrineBundle), giving them support for any cache backend supported in Doctrine, and then having Frameworkbundle only dealing with configuring the Symfony adapter wrapping it (we could also do this in other places allowing to use doctrine-based cache adapter btw).

@jakzal
Copy link
Contributor Author

jakzal commented Jun 25, 2015

@stof the only reason why I haven't done this yet is I couldn't decide how to configure it.

Would this be acceptable?

framework:
    validation:
        cache: 
            doctrine: some.doctrine_cache.service

So cache might be a service id or an array.

weaverryan added a commit to symfony/symfony-docs that referenced this pull request Jun 28, 2015
…bbuh)

This PR was merged into the 2.8 branch.

Discussion
----------

[Reference] document new Doctrine APC cache service

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes (symfony/symfony#14429)
| Applies to    | 2.8+
| Fixed tickets |

Commits
-------

485c8a0 document new Doctrine APC cache service
@fabpot fabpot mentioned this pull request Nov 16, 2015
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.

7 participants