[RFC]: PSR-16 (cache) compatibility
Closed this issue · 4 comments
RFC
Q | A |
---|---|
Proposed Version(s) | 3.0.0 |
BC Break? | Yes/No |
Goal
Change caching logic to be compatible with PSR-16.
Background
There is currently no way to use translation caching feature with a standardized cache component. Indeed, caching logic is only compatible with laminas-cache
component.
It could be interesting to make the cache logic compatible with PSR-16.
Considerations
Main impact would be a change in methods signatures.
It could be possible to maintain a compatibility with direct usage of \Laminas\Cache\Storage\StorageInterface
instance, in order to prevent intoruction of BC break (and so propose this feature in a 2.12.0 version), but IMHO, it could be preferable to remove it, in order to keep the code simple.
Proposal(s)
- Change
Laminas\I18n\Translator\Translator::factory()
options to accept onlyPsr\SimpleCache\CacheInterface
incache
entry. - Change
Laminas\I18n\Translator\Translator::setCache()
to acceptPsr\SimpleCache\CacheInterface|null
as$cache
argument. - Change
Laminas\I18n\Translator\Translator::getCache()
to returnPsr\SimpleCache\CacheInterface|null
. - Adapt internal usage of cache instance to use
Psr\SimpleCache\CacheInterface
methods.
Indeed, caching logic is only compatible with
laminas-cache
component.
Right, because the caching features was added in 2012, before the PSR standard. 😉
…it could be preferable to remove it, in order to keep the code simple.
Code and maintenance. The task for this component is not to create a compatibility layer, but to use available standards directly.
In fact, PSR-16 would be more appropriate, as this component requires only simple get/set/delete cache operations. If you agree, I could rewrite the RFC description to replace PSR-6 by PSR-16.
If you agree, I could rewrite the RFC description to replace PSR-6 by PSR-16.
PSR-16 is a good choice for this package. 👍
Proposed design was not accepted (see #50 ). Another proposal using Decorators pattern have to be proposed.