-
-
Notifications
You must be signed in to change notification settings - Fork 874
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
Add metadata caching #469
Add metadata caching #469
Conversation
3d3016e
to
a0fe215
Compare
I easily get more than 10x performance improvement on a collection get of 30 items. |
0d61a40
to
e935bf3
Compare
*/ | ||
public function create(string $resourceClass, array $options = []) : PropertyNameCollection | ||
{ | ||
$cacheKey = self::CACHE_KEY_PREFIX.md5(json_encode([$resourceClass, $options])); |
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.
serialize
is faster.
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 gave that some thought too, but json_encode produces shorter output. We could always improve on this later on if the performance difference is substantive?
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.
Switched to sha1
since it's (surprisingly) faster than md5
(at least that's what openssl speed md5 sha1
shows on my machine and a Digital Ocean droplet).
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.
Oops, that's not the case in PHP. Let's switch back to md5
.
👍 except for the last comment I made. Good job thank you very much!! |
518fd6d
to
16cb4f8
Compare
ping @api-platform/core-team |
16cb4f8
to
a8eec5c
Compare
Thank you @teohhanhui |
Add PSR6 cached decorators for all metadata factories.
Also provide
symfony/cache
integration in the Symfony bundle.