Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[PropertyInfo] Cache support#16917
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
22c5ede to3d15937Compare3d7efb2 to677b45dCompareThere 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.
instead of passing the cache here I would prefer using composition instead which decorate the default PropertyInfoExtractor something likehttps://gist.github.com/aitboudad/12419c2db6d19320c5fa
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.
same thing for#16838
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.
👍
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.
I was thinking the same thing initially, but finally I'm not sure that it's a good idea:
- Performance (and cache) is not an "optional" feature. It should be enable for all implementations in prod and IMO it's why it belongs to this class.
- In the context of the Standard Edition it adds a lot of complexity and an overhead: it requires to use the service decorator feature to switch the class depending of the environment (the cache must be enabled in prod, but not in dev)
- In the context of the component, it makes it harder to enable the cache (one more class to instantiate)
- all other components using cache doesn't use composition for that (it is considered as a builtin feature)
When the PSR-6 will be ready, the argument can even be made mandatory (it's better to always use a cache) and aNullCache or something like that can be added for the dev environment (like with the Logger).
What do you think @symfony/deciders?
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.
👍 Composition is much cleaner and should be used unless it is not possible, like with the property accessor cache.
dunglas commentedDec 9, 2015
Switched to an implementation to a Decorator as requested. Should the decorator belong to the Doctrine Bridge? IMO no because when PSR-6 will be ready we will switch to this interface instead of Doctrine Cache but I'm open to suggestions. Same if you find a better name for the decorator. |
dunglas commentedDec 14, 2015
ping @symfony/deciders |
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.
double dots
xabbuh commentedDec 15, 2015
Looks like you need to rebase here (the namespace changes have been done in another PR). |
3ed99f3 to436f650Comparedunglas commentedDec 16, 2015
Rebased and typo fixed. |
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.
just wondering: $arguments contains $context. But what does $context contain? Is it a big or small array of scalars? Something potentially non-serializable there?
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.
For now it is only used in Symfony by the serializer extractor (a small array of strings). But it's a good concern because the context can be used by any custom extractor and can contain anything.
Do you know a way to easily retrieve an unique identifier from an array or should we try something like recursively replacing instances of objects by the return ofspl_object_hash()?
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.
Maybe can we add a note in the doc of$context in interfaces that it should only contain scalar and serializable objects or it will create unexpected side effects?
It will avoid to add a costly (in term of performance) custom serialization process here.
dunglas commentedDec 31, 2015
Committed a better way to handle context not serializable. /cc@nicolas-grekas |
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.
This is not really meaningful.
dunglas commentedJan 18, 2016
Status: needs work Should be ported to PSR-6 |
bd1022c to335381bCompare335381b to9396a19Comparedunglas commentedJan 26, 2016
Status: Needs review Moved to PSR-6. |
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.
"psr/cache-implementation": "For using the metadata cache.",?
dunglas commentedJan 26, 2016
@fabpot |
fabpot commentedJan 27, 2016
Thank you@dunglas. |
This PR was squashed before being merged into the 3.1-dev branch (closes#16917).Discussion----------[PropertyInfo] Cache support| Q | A| ------------- | ---| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#16893| License | MIT| Doc PR | todoReplace#16893 with several advantages:- Less complex patch- Work for all usages of PropertyInfo (even outside of the Serializer)- Avoid a circular reference between Serializer's CallMetadataFactory and PropertyInfo's SerializerExtractor- Allow@mihai-stancu's#16143 to work as-isCommits-------86c20df [PropertyInfo] Cache support
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.
setUp is a protected method
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.
Quick search revealed there's few more occurrences. I'll send a PR to fix them.
Replace#16893 with several advantages: