Hi all,

as posted yesterday, I gave PSR-16 a try in Symfony Cache (
https://github.com/symfony/symfony/pull/20636).
This resulted is a number of comments that I summarized in a PR on the
FIG's github repo:
https://github.com/php-fig/fig-standards/pull/846

Here are the collected issues/questions:

On CacheInterface:
- doesn't say what happens when $key is invalid => the same exception as
PSR-6?
- the fact that `getMultiple` returns *all* keys, even cache misses, makes
it impossible to (efficiently) implement a PSR-16 to PSR-6 bridge, because
it makes it impossible to detect cache misses. When given an array,
`apcu_fetch` for example has this other behavior of returning only the
"hit", so it doesn't suffer from this. Could this be worth considering?
- accepting `Traversable` for `*Multiple` methods is not consistent with
PSR-6 which only takes arrays as arguments
- returning `array` for `getMultiple` is not consistent with PSR-6
`getItems` which returns `array|Traversable`
- some methods return `void` when they could return `bool` => this is both
inconsistent with some other methods, and with PSR-6

On CounterInterface:
- the draft doesn't say what happens when $key is invalid => the same
exception as PSR-6?
- nor does it say what happens when $step is not an integer => return
false? throw something?
- what should happen when $key already exists in the storage but is not
"incrementable/integer"? (Redis INCR fails, I didn't check apcu) => return
false? throw? erase and store $step? other?
- atomicity misses a normative MUST or SHOULD.

About exceptions:
- if the PSR is going to document when exceptions should be thrown, then it
should either define new exception classes or reuse those from PSR-6
- reusing exceptions defined in PSR-6 would look the most sensible to me
- yet, they are currently not in the same namespace. But: couldn't all
these new interfaces move in the Psr\Cache namespace (thus releasing them
as psr/cache 1.1 on packagist?)

Best regards,
Nicolas

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to php-fig+unsubscr...@googlegroups.com.
To post to this group, send email to php-fig@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/CAOWwgpkWHWuXAzq-MSCPZ-c%2BGoahPax%2BRAwRse8C_SsXRmUp%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to