[Cache] fix Simple\Psr6Cache proxying of metadata
This commit is contained in:
parent
64e2449f8e
commit
02edc9b049
@ -29,6 +29,8 @@ class Psr6Cache implements CacheInterface, PruneableInterface, ResettableInterfa
|
|||||||
{
|
{
|
||||||
use ProxyTrait;
|
use ProxyTrait;
|
||||||
|
|
||||||
|
private const METADATA_EXPIRY_OFFSET = 1527506807;
|
||||||
|
|
||||||
private $createCacheItem;
|
private $createCacheItem;
|
||||||
private $cacheItemPrototype;
|
private $cacheItemPrototype;
|
||||||
|
|
||||||
@ -58,7 +60,7 @@ class Psr6Cache implements CacheInterface, PruneableInterface, ResettableInterfa
|
|||||||
}
|
}
|
||||||
$this->createCacheItem = $createCacheItem;
|
$this->createCacheItem = $createCacheItem;
|
||||||
|
|
||||||
return $createCacheItem($key, $value, $allowInt);
|
return $createCacheItem($key, null, $allowInt)->set($value);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,8 +149,29 @@ class Psr6Cache implements CacheInterface, PruneableInterface, ResettableInterfa
|
|||||||
}
|
}
|
||||||
$values = array();
|
$values = array();
|
||||||
|
|
||||||
|
if (!$this->pool instanceof AdapterInterface) {
|
||||||
|
foreach ($items as $key => $item) {
|
||||||
|
$values[$key] = $item->isHit() ? $item->get() : $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($items as $key => $item) {
|
foreach ($items as $key => $item) {
|
||||||
$values[$key] = $item->isHit() ? $item->get() : $default;
|
if (!$item->isHit()) {
|
||||||
|
$values[$key] = $default;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$values[$key] = $item->get();
|
||||||
|
|
||||||
|
if (!$metadata = $item->getMetadata()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
unset($metadata[CacheItem::METADATA_TAGS]);
|
||||||
|
|
||||||
|
if ($metadata) {
|
||||||
|
$values[$key] = array("\x9D".pack('VN', (int) $metadata[CacheItem::METADATA_EXPIRY] - self::METADATA_EXPIRY_OFFSET, $metadata[CacheItem::METADATA_CTIME])."\x5F" => $values[$key]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
|
@ -11,8 +11,9 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||||
|
|
||||||
|
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||||
use Symfony\Component\Cache\Adapter\SimpleCacheAdapter;
|
use Symfony\Component\Cache\Adapter\SimpleCacheAdapter;
|
||||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
use Symfony\Component\Cache\Simple\Psr6Cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group time-sensitive
|
* @group time-sensitive
|
||||||
@ -25,6 +26,6 @@ class SimpleCacheAdapterTest extends AdapterTestCase
|
|||||||
|
|
||||||
public function createCachePool($defaultLifetime = 0)
|
public function createCachePool($defaultLifetime = 0)
|
||||||
{
|
{
|
||||||
return new SimpleCacheAdapter(new FilesystemCache(), '', $defaultLifetime);
|
return new SimpleCacheAdapter(new Psr6Cache(new FilesystemAdapter()), '', $defaultLifetime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user