-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Validate injector cache saved and optimize local cache selection #417
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## 1.x #417 +/- ##
=========================================
Coverage 99.87% 99.87%
Complexity 243 243
=========================================
Files 54 54
Lines 814 816 +2
=========================================
+ Hits 813 815 +2
Misses 1 1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
ray-di/Ray.PsrCacheModule#17 で Ray.PsrCacheModule のリリースを行った後にcomposer.jsonを修正します。 |
src/Injector.php
Outdated
@@ -26,7 +25,7 @@ public static function getInstance(string $appName, string $context, string $app | |||
{ | |||
$meta = new Meta($appName, $context, $appDir); | |||
$cacheNamespace = str_replace('/', '_', $appDir) . $context; | |||
$cache ??= ApcuAdapter::isSupported() ? new ApcuAdapter($cacheNamespace) : new FilesystemAdapter('', 0, $meta->tmpDir . '/injector'); | |||
$cache = (new LocalCacheProvider($meta->tmpDir . '/injector', $cacheNamespace))->get(); |
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.
受け取った $cache の値に関わらず LocalCacheProvider の値に置き換えてしまっていますかね?
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.
修正しました!
Symfonyはキャッシュが失敗したときにLogに記録して
https://github.com/symfony/cache/blob/v5.4.22/Traits/AbstractAdapterTrait.php#L230
その後trigger_errorでエラー発生させますが、
@
で抑制されていてエラーハンドラーで検出しないとユーザーが気がつきません。https://github.com/symfony/cache/blob/v5.4.22/CacheItem.php#L189
このPRはキャッシュの検証を行い、検出可能にします。
それに加え、ローカルキャッシュの判定を修正し、CLIのときにApcuAdapterを使わないようにしました。
27c7d8e
Symfony logs cache failures to
https://github.com/symfony/cache/blob/v5.4.22/Traits/AbstractAdapterTrait.php#L230
It then raises an error with trigger_error, but it is suppressed with
@
and the user will not notice it unless it is detected by the error handler.https://github.com/symfony/cache/blob/v5.4.22/CacheItem.php#L189
This PR validates the cache and makes it detectable.