for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nip\Filesystem;
use Psr\SimpleCache\CacheInterface;
use League\Flysystem\Cached\Storage\AbstractCache;
/**
* Class Cache
* @package Nip\Filesystem
*/
class Cache extends AbstractCache
{
* The cache repository implementation.
*
* @var \Psr\SimpleCache\CacheInterface
protected $repository;
* The cache key.
* @var string
protected $key;
* The cache expiration time in seconds.
* @var int|null
protected $expire;
* Create a new cache instance.
* @param \Psr\SimpleCache\CacheInterface $repository
* @param string $key
* @param int|null $expire
* @return void
@return
Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.
Please refer to the PHP core documentation on constructors.
public function __construct(CacheInterface $repository, $key = 'flysystem', $expire = null)
$this->key = $key;
$this->expire = $expire;
$this->repository = $repository;
}
* Load the cache.
public function load()
$contents = $this->repository->get($this->key);
if (!is_null($contents)) {
$this->setFromStorage($contents);
* Persist the cache.
public function save()
$contents = $this->getForStorage();
$this->repository->set($this->key, $contents, $this->expire);
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.