vendor/symfony/cache/DoctrineProvider.php line 54

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Cache;
  11. use Doctrine\Common\Cache\CacheProvider;
  12. use Psr\Cache\CacheItemPoolInterface;
  13. use Symfony\Contracts\Service\ResetInterface;
  14. /**
  15.  * @author Nicolas Grekas <p@tchwork.com>
  16.  */
  17. class DoctrineProvider extends CacheProvider implements PruneableInterfaceResettableInterface
  18. {
  19.     private $pool;
  20.     public function __construct(CacheItemPoolInterface $pool)
  21.     {
  22.         $this->pool $pool;
  23.     }
  24.     /**
  25.      * {@inheritdoc}
  26.      */
  27.     public function prune()
  28.     {
  29.         return $this->pool instanceof PruneableInterface && $this->pool->prune();
  30.     }
  31.     /**
  32.      * {@inheritdoc}
  33.      */
  34.     public function reset()
  35.     {
  36.         if ($this->pool instanceof ResetInterface) {
  37.             $this->pool->reset();
  38.         }
  39.         $this->setNamespace($this->getNamespace());
  40.     }
  41.     /**
  42.      * {@inheritdoc}
  43.      *
  44.      * @return mixed
  45.      */
  46.     protected function doFetch($id)
  47.     {
  48.         $item $this->pool->getItem(rawurlencode($id));
  49.         return $item->isHit() ? $item->get() : false;
  50.     }
  51.     /**
  52.      * {@inheritdoc}
  53.      *
  54.      * @return bool
  55.      */
  56.     protected function doContains($id)
  57.     {
  58.         return $this->pool->hasItem(rawurlencode($id));
  59.     }
  60.     /**
  61.      * {@inheritdoc}
  62.      *
  63.      * @return bool
  64.      */
  65.     protected function doSave($id$data$lifeTime 0)
  66.     {
  67.         $item $this->pool->getItem(rawurlencode($id));
  68.         if ($lifeTime) {
  69.             $item->expiresAfter($lifeTime);
  70.         }
  71.         return $this->pool->save($item->set($data));
  72.     }
  73.     /**
  74.      * {@inheritdoc}
  75.      *
  76.      * @return bool
  77.      */
  78.     protected function doDelete($id)
  79.     {
  80.         return $this->pool->deleteItem(rawurlencode($id));
  81.     }
  82.     /**
  83.      * {@inheritdoc}
  84.      *
  85.      * @return bool
  86.      */
  87.     protected function doFlush()
  88.     {
  89.         return $this->pool->clear();
  90.     }
  91.     /**
  92.      * {@inheritdoc}
  93.      *
  94.      * @return array|null
  95.      */
  96.     protected function doGetStats()
  97.     {
  98.         return null;
  99.     }
  100. }