psr/simple-cache
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The PSR/Simple-Cache is a PHP composer package that provides common interfaces for simple caching. It abides by PSR-16 standards. Basically, it's not a standalone cache implementation, but an interface that outlines what caching implementation should look like. It standardizes cache interaction in PHP, which allows developers to shift between different caching solutions without a significant change in code.
Utilizing the PSR/Simple-Cache package is easy and straightforward. You include it in your project through composer, and then you can use it as stated by the PSR-16 caching interface.
For instance, to include the package in your project, you would use:
composer require psr/simple-cache
And a basic usage example might look like:
use Psr\SimpleCache\CacheInterface;
class MyClass
{
private $cache;
public function __construct(CacheInterface $cache)
{
$this->cache = $cache;
}
public function getItemFromCache($key)
{
if ($this->cache->has($key)) {
return $this->cache->get($key);
}
// item does not exist in the cache.
return null;
}
}
Please note that PSR/Simple-Cache is just the interface for caching as per PSR-16 and you'll need an actual implementation for this to work.
All the documentation related to the PSR/Simple-Cache, including how it ties to the PSR-16 standard, can be found within the official specification file on the PHP-FIG GitHub. You can access it from the link provided in the README of the package at PSR-16 Simple Cache Specs.