Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle] Allow custom services for validator mapping cache.#12975
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
fabpot commentedDec 24, 2014
Thank you@jakzal. |
…ing cache. (jakzal)This PR was merged into the 2.5 branch.Discussion----------[FrameworkBundle] Allow custom services for validator mapping cache.| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#12803| License | MIT| Doc PR | -#9892 introduced `DoctrineCache`, but it's not really used by the FrameworkBundle. This was overlooked, therefore I think it should go into 2.5.This PR will let us to configure a service id, instead of a driver name. The only exception is apc, which is converted to `validator.mapping.cache.apc` to keep BC.Examples:```yamlframework: validation: cache: apc # converted to validator.mapping.cache.apc``````yamlframework: validation: cache: my_custom_cache_service```It would be nice to be able to provide a doctrine service id, instead of `CacheInterface` implementation. It could be automatically decorated with `DoctrineCache`:```yamlframework: validation: cache: doctrine: my_doctrine_cache_service # could be provided by DoctrineCacheBundle```I'll work on it next.Commits-------4cdcf10 [FrameworkBundle] Allow custom services for validator mapping cache.
jakzal commentedDec 24, 2014
Note that a cache service implementing our interface still needs to be created by the end user. At least it's possible now. I'll work on making it easier next. |
xabbuh commentedDec 29, 2014
Just two quick questions about this change:
|
weaverryan commentedDec 29, 2014
I agree with@xabbuh - this looks like a very small BC break. But if you're relying on this behavior, things would blow up when your container is being built, so it'll be an obvious (and small) BC break. So perhaps it's "ok"? |
cmodijk commentedMar 11, 2015
@jakzal Did you ever get to implement the doctrine decorator? |
jakzal commentedApr 21, 2015
@cmodijk no, but all you have to do in your own project is to register a new caching service: <serviceid="my_validator_mapping_cache"class="Symfony\Component\Validator\Mapping\Cache\DoctrineCache"public="false"> <argumenttype="service"> <serviceclass="Doctrine\Common\Cache\ApcCache"> <callmethod="setNamespace"> <argument>%validator.mapping.cache.prefix%</argument> </call> </service> </argument> </service> and tell validator to use it: framework:validation:cache:my_validator_mapping_cache |
cmodijk commentedApr 23, 2015
Hmm yeah but it would be nice to directly give a doctrine cache service and that the wrapping is done by Symfony because of the fact that you have thehttps://github.com/doctrine/DoctrineCacheBundle that generates these service id's for you. Know you need to create your own service just to wrap around the cache. With the possibility to directly inject the doctrine cache service id you don't need anything extra. |
pwm commentedJun 17, 2015
Hi, is there a way to do this using Redis? |
jakzal commentedJun 18, 2015
@pwm yes, see the supported drivers here:https://github.com/doctrine/cache/tree/master/lib/Doctrine/Common/Cache |
…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#5409Following#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`:```yamlframework: 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
DoctrineCache, but it's not really used by the FrameworkBundle. This was overlooked, therefore I think it should go into 2.5.This PR will let us to configure a service id, instead of a driver name. The only exception is apc, which is converted to
validator.mapping.cache.apcto keep BC.Examples:
It would be nice to be able to provide a doctrine service id, instead of
CacheInterfaceimplementation. It could be automatically decorated withDoctrineCache:I'll work on it next.