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.     protected function doFetch($id)
  45.     {
  46.         $item $this->pool->getItem(rawurlencode($id));
  47.         return $item->isHit() ? $item->get() : false;
  48.     }
  49.     /**
  50.      * {@inheritdoc}
  51.      *
  52.      * @return bool
  53.      */
  54.     protected function doContains($id)
  55.     {
  56.         return $this->pool->hasItem(rawurlencode($id));
  57.     }
  58.     /**
  59.      * {@inheritdoc}
  60.      *
  61.      * @return bool
  62.      */
  63.     protected function doSave($id$data$lifeTime 0)
  64.     {
  65.         $item $this->pool->getItem(rawurlencode($id));
  66.         if ($lifeTime) {
  67.             $item->expiresAfter($lifeTime);
  68.         }
  69.         return $this->pool->save($item->set($data));
  70.     }
  71.     /**
  72.      * {@inheritdoc}
  73.      *
  74.      * @return bool
  75.      */
  76.     protected function doDelete($id)
  77.     {
  78.         return $this->pool->deleteItem(rawurlencode($id));
  79.     }
  80.     /**
  81.      * {@inheritdoc}
  82.      *
  83.      * @return bool
  84.      */
  85.     protected function doFlush()
  86.     {
  87.         return $this->pool->clear();
  88.     }
  89.     /**
  90.      * {@inheritdoc}
  91.      *
  92.      * @return array|null
  93.      */
  94.     protected function doGetStats()
  95.     {
  96.         return null;
  97.     }
  98. }