-
Notifications
You must be signed in to change notification settings - Fork 447
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
Introduce cache drivers #200
Conversation
671b161
to
4e66622
Compare
@GrahamCampbell thank you for putting the time to review but, as I've tried to explain in the commit message, these implementations are naive on purpose. |
I really think it's best to provide nothing at all, than non-compliant implementations. The point of the PSR interop is not to have fewer dependencies, but to give the user a choice of what to use. Maybe just "suggest" a the psr cache implementation virtual package, and provide no implementations? |
I get your point, though to not provide anything we'd have to break the previous API. We can drop the null thing by reworking a few things but the simple file one must be kept for the bc reason. So I defer this to @nikic |
I don't really have a problem with breaking API for the next major version, if necessary. Some thoughts on this PR:
|
I suppose the use case is php-fpm not having write permission to the disk? |
@GrahamCampbell If php-fpm does not have write permissions, that implies that the application must be using pre-deploy cache population, where the FastRoute cache should also be generated. Possibly this is not really easy to integrate right now though? |
I understood from the original issue that people did want to use a different caching driver. We can definitely invert the relationship and provide an adapter for PSR-16. I'd still provide the
Invalidation is tricky, using other drivers it gets worse. Although I'd treat this kind of thing as we do for metadata cache in Doctrine ORM: let people control it outside of the application life cycle. The problem is not about how to invalidate but rather when.
This addresses #140 and not #141 indeed. @nikic my main concern here is that I feel like you don't see value in supporting multiple cache drivers and am afraid that this might be a poor use of my time... I'm wiling to rework this whole thing if you say it's something we want for v2 but if not let's just close it 👍 |
Lock file operations: 1 install, 20 updates, 0 removals - Upgrading doctrine/annotations (1.12.1 => 1.13.1) - Upgrading phpbench/phpbench (1.0.0 => 1.0.2) - Upgrading phpstan/phpstan (0.12.86 => 0.12.89) - Upgrading phpstan/phpstan-phpunit (0.12.18 => 0.12.19) - Upgrading phpunit/phpunit (9.5.4 => 9.5.5) - Locking psr/cache (1.0.1) - Upgrading sebastian/global-state (5.0.2 => 5.0.3) - Upgrading sebastian/type (2.3.1 => 2.3.2) - Upgrading slevomat/coding-standard (7.0.8 => 7.0.9) - Upgrading symfony/console (v5.2.7 => v5.3.0) - Upgrading symfony/filesystem (v5.2.7 => v5.3.0) - Upgrading symfony/finder (v5.2.4 => v5.3.0) - Upgrading symfony/options-resolver (v5.2.4 => v5.3.0) - Upgrading symfony/polyfill-ctype (v1.22.1 => v1.23.0) - Upgrading symfony/polyfill-intl-grapheme (v1.22.1 => v1.23.0) - Upgrading symfony/polyfill-intl-normalizer (v1.22.1 => v1.23.0) - Upgrading symfony/polyfill-mbstring (v1.22.1 => v1.23.0) - Upgrading symfony/polyfill-php73 (v1.22.1 => v1.23.0) - Upgrading symfony/polyfill-php80 (v1.22.1 => v1.23.0) - Upgrading symfony/process (v5.2.7 => v5.3.0) - Upgrading symfony/string (v5.2.6 => v5.3.0)
81ac50f
to
28c6046
Compare
Allowing users to vary the implementation of route caching according to their needs. This makes the file system based cache a bit more robust by using exclusive locking and preventing reads of partial files. We're also adding an APCu-based implementation, so that we can compare FastRoute to HackRouting. More info: - https://github.com/azjezz/hack-routing - https://github.com/azjezz/benchmark-php-routing
28c6046
to
2e3166d
Compare
The APCu cache is meant to be used by users who know that APCu is installed, as it requires explicit configuration of the caching driver.
2e3166d
to
a53d563
Compare
@nikic I've reorganised my proposal according to the discussion. The file-based cache now does exclusive locks and atomic renames to avoid a corrupted state. The interface is also straightforward now, allowing us to add new implementations (e.g.: supporting closures). Would you have a look, please? |
@nikic I decided to get this merged for now. Please review it whenever you have the time for it and we can improve things. |
While I appreciate the work that has gone into this, and fully understanding that I am not a contributor to the project, I would like to raise two concerns:
|
@designermonkey thanks for sharing your thoughts.
Indeed, not have a review isn't ideal. However, we've got extensive tests and benchmarks that give enough information not to block this PR. I do invite you to review the code and share your findings here or on a PR.
I've indeed overlooked the documentation and will correct my mistake ASAP. In the meantime, feel free to send a PR - maybe you're faster than me. |
Fixes #140
This provides a caching interface and implementations for the most common drivers (filesystem and APCu).
Users can create their own implementation of the interface to support PSR-6/PSR-16/anything else.