Skip to content
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

[RFC]: PSR-16 (cache) compatibility #49

Closed
cedric-anne opened this issue May 7, 2021 · 4 comments · May be fixed by #120
Closed

[RFC]: PSR-16 (cache) compatibility #49

cedric-anne opened this issue May 7, 2021 · 4 comments · May be fixed by #120

Comments

@cedric-anne
Copy link
Contributor

cedric-anne commented May 7, 2021

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 only Psr\SimpleCache\CacheInterface in cache entry.
  • Change Laminas\I18n\Translator\Translator::setCache() to accept Psr\SimpleCache\CacheInterface|null as $cache argument.
  • Change Laminas\I18n\Translator\Translator::getCache() to return Psr\SimpleCache\CacheInterface|null.
  • Adapt internal usage of cache instance to use Psr\SimpleCache\CacheInterface methods.
@cedric-anne cedric-anne added the RFC label May 7, 2021
@froschdesign
Copy link
Member

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.

@froschdesign froschdesign added this to the 3.0.0 milestone May 7, 2021
@cedric-anne
Copy link
Contributor Author

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.

@froschdesign
Copy link
Member

@cedric-anne

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. 👍

@cedric-anne cedric-anne changed the title [RFC]: PSR-6 (cache) compatibility [RFC]: PSR-16 (cache) compatibility May 10, 2021
@cedric-anne
Copy link
Contributor Author

Proposed design was not accepted (see #50 ). Another proposal using Decorators pattern have to be proposed.

@froschdesign froschdesign removed this from the 3.0.0 milestone Nov 3, 2021
PowerKiKi pushed a commit to PowerKiKi/laminas-i18n that referenced this issue Apr 25, 2024
Closes laminas#49

Signed-off-by: Cédric Anne <[email protected]>
PowerKiKi pushed a commit to PowerKiKi/laminas-i18n that referenced this issue Apr 25, 2024
Closes laminas#49

Signed-off-by: Cédric Anne <[email protected]>
Signed-off-by: Adrien Crivelli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants