-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Cache] Implement PSR-16 SimpleCache v1.0 #20694
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
Conversation
parent::__construct($namespace, $defaultLifetime); | ||
|
||
$this->pool = $pool; | ||
$this->miss = new stdClass(); |
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.
missing \
here
*/ | ||
protected function doFetch(array $ids) | ||
{ | ||
foreach ($this->pool->getMultiple($ids, $this->miss) as $key => $value) { |
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 call would be performed only when the iteration starts rather than when doFetch
is called. Is it an issue ?
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.
The ids have already been validated by the AbstractAdapter. Since this is the only situation that is allowed to throw, it's OK this way to me.
} catch (SimpleCacheException $e) { | ||
throw $e; | ||
} catch (Psr6CacheException $e) { | ||
throw new InvalidArgumentException($e->getMessage()); |
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 would link the original exception as previous exception, to keep the original stack trace (same everywhere of course)
@Seldaek @nicolas-grekas @dragoonis @Nyholm it may be worth starting the work on a shared testsuite for simple-cache too (similar to the one existing for PSR-6) |
acd7065
to
72ba3a3
Compare
Status: needs review I'd propose to merge this PR without waiting for more tests nor for more progress from the fig. This would unlock some other things I'd like to do on top of this one, but deserve another PR. |
} catch (SimpleCacheException $e) { | ||
throw $e; | ||
} catch (Psr6CacheException $e) { | ||
throw new InvalidArgumentException($e->getMessage()); |
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.
here (and similar below), I think we don't need to add $e as a "previous" to the thrown exception: by PSR-6, there can be only one reason for the $e exception: invalid key. Having the previous throwing site (file, line, stack) is not going to help: the error is the $key, so the message is the only thing that is useful IMHO.
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 could be a second reason: misbehaving cache implementation. In this case, knowing the original location of the exception could help understand whether the issue is in the key, or in the key validation. And btw, it would still point people to the code implementing the key validation, showing them the logic used to validate it.
So IMO, it is still a good idea to link the original exception.
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.
OK, added
{ | ||
protected $skippedTests = array( | ||
'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.', | ||
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.', |
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.
should we run a second set of tests for the SimpleCacheAdapter by making it use a shared cache internally ?
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.
ArrayAdapter replaced by FilesystemAdapter
} catch (SimpleCacheException $e) { | ||
throw $e; | ||
} catch (Psr6CacheException $e) { | ||
throw new InvalidArgumentException($e->getMessage()); |
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 could be a second reason: misbehaving cache implementation. In this case, knowing the original location of the exception could help understand whether the issue is in the key, or in the key validation. And btw, it would still point people to the code implementing the key validation, showing them the logic used to validate it.
So IMO, it is still a good idea to link the original exception.
da68dae
to
e543588
Compare
@Nyholm @nicolas-grekas have you made any progress on the shared PSR-16 testsuite ? |
Yes. I do. Expect it to be done at the very latest this weekend. |
Looking forward to seeing it :)
…On Tue, Jan 3, 2017 at 5:29 PM, Tobias Nyholm ***@***.***> wrote:
Yes. I do. Expect it to be done at the very latest this weekend.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20694 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAI7kVEVrbPN_eQ9W57oTP6Ns9H8VjKcks5rOoV3gaJpZM4LAAFV>
.
|
Test PR is here: php-cache/integration-tests#66 |
e543588
to
fadc638
Compare
fadc638
to
0610dd8
Compare
e28b69c
to
5491454
Compare
php-cache/integration-tests v0.14.0 integrated, tests green. |
1ae92f6
to
f1a6827
Compare
Status: needs review |
e527505
to
2b5cc7f
Compare
781b9d2
to
0ab20ae
Compare
0ab20ae
to
5b9e9b4
Compare
5b9e9b4
to
6219dd6
Compare
Thank you @nicolas-grekas. |
…kas) This PR was squashed before being merged into the 3.3-dev branch (closes #20694). Discussion ---------- [Cache] Implement PSR-16 SimpleCache v1.0 | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | not yet | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#7409 Second iteration on the topic after #20636 raised some issues. Please don't squash while merging. Commits ------- 6219dd6 [Cache] Create PSR-16 variants of all PSR-6 adapters 99ae9d6 [Cache] Move adapter implementations to traits 848a33e [Cache] Implement PSR-16 SimpleCache v1.0
👍 🥇 |
Second iteration on the topic after #20636 raised some issues.
Please don't squash while merging.