* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Adapter; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ProxyTrait; /** * @author Nicolas Grekas */ class ProxyAdapter implements AdapterInterface, PruneableInterface, ResettableInterface { use ProxyTrait; private $namespace; private $namespaceLen; private $createCacheItem; private $poolHash; /** * @param CacheItemPoolInterface $pool * @param string $namespace * @param int $defaultLifetime */ public function __construct(CacheItemPoolInterface $pool, $namespace = '', $defaultLifetime = 0) { $this->pool = $pool; $this->poolHash = $poolHash = spl_object_hash($pool); $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace); $this->namespaceLen = strlen($namespace); $this->createCacheItem = \Closure::bind( function ($key, $innerItem) use ($defaultLifetime, $poolHash) { $item = new CacheItem(); $item->key = $key; $item->value = $innerItem->get(); $item->isHit = $innerItem->isHit(); $item->defaultLifetime = $defaultLifetime; $item->innerItem = $innerItem; $item->poolHash = $poolHash; $innerItem->set(null); return $item; }, null, CacheItem::class ); } /** * {@inheritdoc} */ public function getItem($key) { $f = $this->createCacheItem; $item = $this->pool->getItem($this->getId($key)); return $f($key, $item); } /** * {@inheritdoc} */ public function getItems(array $keys = array()) { if ($this->namespaceLen) { foreach ($keys as $i => $key) { $keys[$i] = $this->getId($key); } } return $this->generateItems($this->pool->getItems($keys)); } /** * {@inheritdoc} */ public function hasItem($key) { return $this->pool->hasItem($this->getId($key)); } /** * {@inheritdoc} */ public function clear() { return $this->pool->clear(); } /** * {@inheritdoc} */ public function deleteItem($key) { return $this->pool->deleteItem($this->getId($key)); } /** * {@inheritdoc} */ public function deleteItems(array $keys) { if ($this->namespaceLen) { foreach ($keys as $i => $key) { $keys[$i] = $this->getId($key); } } return $this->pool->deleteItems($keys); } /** * {@inheritdoc} */ public function save(CacheItemInterface $item) { return $this->doSave($item, __FUNCTION__); } /** * {@inheritdoc} */ public function saveDeferred(CacheItemInterface $item) { return $this->doSave($item, __FUNCTION__); } /** * {@inheritdoc} */ public function commit() { return $this->pool->commit(); } private function doSave(CacheItemInterface $item, $method) { if (!$item instanceof CacheItem) { return false; } $item = (array) $item; $expiry = $item["\0*\0expiry"]; if (null === $expiry && 0 < $item["\0*\0defaultLifetime"]) { $expiry = time() + $item["\0*\0defaultLifetime"]; } $innerItem = $item["\0*\0poolHash"] === $this->poolHash ? $item["\0*\0innerItem"] : $this->pool->getItem($this->namespace.$item["\0*\0key"]); $innerItem->set($item["\0*\0value"]); $innerItem->expiresAt(null !== $expiry ? \DateTime::createFromFormat('U', $expiry) : null); return $this->pool->$method($innerItem); } private function generateItems($items) { $f = $this->createCacheItem; foreach ($items as $key => $item) { if ($this->namespaceLen) { $key = substr($key, $this->namespaceLen); } yield $key => $f($key, $item); } } private function getId($key) { CacheItem::validateKey($key); return $this->namespace.$key; } } __halt_compiler();----SIGNATURE:----YSa3lFY8PayVEPKVzkK8t4WkuZVoN+beiz9kWObSXM51362PCIOaf8rHd4EAKgkvD7gDLJEv2DSB7Zt0HDmDfGxiCtoJVZghRcozDaasUN3i6q50qwyA6KMYheyrtVDvDDJ8IXHBC1Hsoz7R9JwyP1ZpDWPiXXsBXj6rEBavjw8Py3kRa8jRJXtx65pizXINEmfeGZ/rWAtdnZKhD8al2Coe5kEE8k8lMIuMAp1dQZ1/iLQxIssqFrXjJWgU8/6aRu/lm8UOm3ihZVzeymNSBE0Kaf/IGJx8dfOj9BAdKc8smA0xEs4De4U+z/V15xcSUy9Spyep1tlDbliZwdNvLUhyP2o9oUn6dXzUmcSqzUIiveQvDp/iEVZiPpJGfVyMYLQUjY/9IkmYcARhue87tet5Rdegvdm9LWNIybb/uaM4m4mRpSeV43xo7bhrsukQRTP4N3a/uCfU7BmHA/uLedTtVItRcHy+bHrFh5kBsKl24n8k43nxt3FtH0jwPq0+9Jr0JWqvlpXnFElmFXY0/KF5yAPOljVcLu4n7isQoy8W0pojhNaxMANT5pEYya4wIQxZFOEclzTv/Y/6bEU9xz8HpCLHYyGgH4pgZwf/rlP4+t/Ijls49bzgznpHJxUcAv6kMBhIH0VYyaaBMBQTkifCTq3G9ZKlEqJzG7eAKDc=----ATTACHMENT:----OTU2Njc3OTM4OTY4NzQzIDMwNjU1NTgzMDc4NDU3ODMgMzc4MTk5ODYyMzA5Mzc3NA==