实现请求缓存1天。

This commit is contained in:
2025-04-18 15:38:58 +08:00
parent 2d3f7d8511
commit 96da83a1ab
209 changed files with 19400 additions and 1657 deletions
@@ -0,0 +1,52 @@
<?php
namespace Kevinrob\GuzzleCache\Storage;
use Kevinrob\GuzzleCache\CacheEntry;
use Psr\SimpleCache\CacheInterface;
class Psr16CacheStorage implements CacheStorageInterface
{
/**
* @var CacheInterface
*/
private $cache;
public function __construct(CacheInterface $cache)
{
$this->cache = $cache;
}
/**
* {@inheritdoc}
*/
public function fetch($key)
{
$data = $this->cache->get($key);
if ($data instanceof CacheEntry) {
return $data;
}
return null;
}
/**
* {@inheritdoc}
*/
public function save($key, CacheEntry $data)
{
$ttl = $data->getTTL();
if ($ttl === 0) {
return $this->cache->set($key, $data);
}
return $this->cache->set($key, $data, $data->getTTL());
}
/**
* {@inheritdoc}
*/
public function delete($key)
{
return $this->cache->delete($key);
}
}