Caching is a common way to improve the performance of any project, and many libraries make use or could make use of it. Interoperability at this level means libraries can drop their own caching implementations and easily rely on the one given to them by the framework, or another dedicated cache library the user picked.
PSR-6 solves this problem already, but in a rather formal and verbose way for what the most simple use cases need. This simpler approach aims to build a standardized layer of simplicity on top of the existing PSR-6 interfaces.
The approach chosen here is very barebones by design, as it is to be used only by the most simple cases. It does not have to be implementable by all possible cache backends, nor be usable for all usages. It is merely a layer of convenience on top of PSR-6.
For their role in the writing the initial version of this cache PSR:
For being an early reviewer
The 2.0 release of the psr/simple-cache
package updates Psr\SimpleCache\CacheException
to extend \Throwable
. This is considered a backwards compatible change for implementing libraries as of PHP 7.4.
The 2.0 release of the psr/simple-cache
package includes scalar parameter types and increases the minimum PHP version to 8.0. This is considered a backwards compatible change for implementing libraries as PHP 7.2 introduces covariance for parameters. Any implementation of 1.0 is compatible with 2.0. For calling libraries, however, this reduces the types that they may pass (as previously any parameter that could be cast to string could be accepted) and as such requires incrementing the major version.
The 3.0 release includes return types. Return types break backwards compatibility for implementing libraries as PHP does not support return type widening.
Implementing libraries MAY add return types to their own packages at their discretion, provided that:
"psr/simple-cache": "^2 || ^3"
so as to exclude the untyped 1.0 version.Implementing libraries MAY add parameter types to their own package in a new minor release, either at the same time as adding return types or in a subsequent release, provided that:
"psr/simple-cache": "^2 || ^3"
so as to exclude the untyped 1.0 version.Implementing libraries are encouraged, but not required to transition their packages toward the 3.0 version of the package at their earliest convenience.
Calling libraries are encouraged to ensure they are sending the correct types and to update their requirement to "psr/simple-cache": "^1 || ^2 || ^3"
at their earliest convenience.