vendor/symfony/symfony/src/Symfony/Component/Cache/DoctrineProvider.php line 53

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. /**
  14.  * @author Nicolas Grekas <p@tchwork.com>
  15.  */
  16. class DoctrineProvider extends CacheProvider implements PruneableInterfaceResettableInterface
  17. {
  18.     private $pool;
  19.     public function __construct(CacheItemPoolInterface $pool)
  20.     {
  21.         $this->pool $pool;
  22.     }
  23.     /**
  24.      * {@inheritdoc}
  25.      */
  26.     public function prune()
  27.     {
  28.         return $this->pool instanceof PruneableInterface && $this->pool->prune();
  29.     }
  30.     /**
  31.      * {@inheritdoc}
  32.      */
  33.     public function reset()
  34.     {
  35.         if ($this->pool instanceof ResettableInterface) {
  36.             $this->pool->reset();
  37.         }
  38.         $this->setNamespace($this->getNamespace());
  39.     }
  40.     /**
  41.      * {@inheritdoc}
  42.      */
  43.     protected function doFetch($id)
  44.     {
  45.         $item $this->pool->getItem(rawurlencode($id));
  46.         return $item->isHit() ? $item->get() : false;
  47.     }
  48.     /**
  49.      * {@inheritdoc}
  50.      */
  51.     protected function doContains($id)
  52.     {
  53.         return $this->pool->hasItem(rawurlencode($id));
  54.     }
  55.     /**
  56.      * {@inheritdoc}
  57.      */
  58.     protected function doSave($id$data$lifeTime 0)
  59.     {
  60.         $item $this->pool->getItem(rawurlencode($id));
  61.         if ($lifeTime) {
  62.             $item->expiresAfter($lifeTime);
  63.         }
  64.         return $this->pool->save($item->set($data));
  65.     }
  66.     /**
  67.      * {@inheritdoc}
  68.      */
  69.     protected function doDelete($id)
  70.     {
  71.         return $this->pool->deleteItem(rawurlencode($id));
  72.     }
  73.     /**
  74.      * {@inheritdoc}
  75.      */
  76.     protected function doFlush()
  77.     {
  78.         return $this->pool->clear();
  79.     }
  80.     /**
  81.      * {@inheritdoc}
  82.      */
  83.     protected function doGetStats()
  84.     {
  85.         return null;
  86.     }
  87. }