* * 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:----HMeO7PoprEl+vjtbjTQYBIktrxpS4sBODJRZVHDJkTY8REafeULiAboTQjitnsdmevFn8vFTmB5w6iqLbHyf1jZ1dl8maTuBmYqlC6SwYXDo1cuxIDNcZiPXc8dgL72AG0MiZgCjz9AbC+xo5Mjn2T/ykeQeIb0Gv5X7RHrr0jc7gheax/nFuZQikaUAAK21gVqKZTrgk2Fg3bRFC588aLL6VP6ry+bfe9SjW5YcLoCW6lTOcg1ScHjtGZjkulwEw5WBkhfqT0IUEoGp53uHNul/v4MU+zcuP1+0Hhpr/LnDgG5k4Dn/rl/w+VPTRi8DC9WQgdz2eoE2wFX8Wo/ECHG5lJXviNzxbQ7c9+zhNkhkrKGr0YQmHwFCBCDoMwv6mwhtw12tW2I4ahbtS+ksVh6HDdIENSJHZnHkDVw6uIZTE8JEBHdZ4xQ5VeWkUnbKngSRCi8h21gohEU/27LmW99LnMk8CazaJWtklTbpX+WaGthNnwJ9xqemVLWTXvQb9JkFVlPF81AA+0IWrrIdpiZk6jdZdsHwXQkjDz64/7pdPeAmJWabCp1R20ex7/VbOazOsYO5yCb6+SKpZkbW2CRrUTHY2VfAoS5A8b7Lu80kTeG+SSETfkspGHidjX+ESdDZMdRmSXEVCrCnlOT+3GYsBg0ElKg3ByyGJ+e2Ocw=----ATTACHMENT:----OTExODU4MDg5MTY5MzEwMiA0NzQzMzcxNzczNTA0OTk3IDE1MTgxODU0NzQwMDU5OQ==