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.     protected function doContains($id)
  53.     {
  54.         return $this->pool->hasItem(rawurlencode($id));
  55.     }
  56.     /**
  57.      * {@inheritdoc}
  58.      */
  59.     protected function doSave($id$data$lifeTime 0)
  60.     {
  61.         $item $this->pool->getItem(rawurlencode($id));
  62.         if ($lifeTime) {
  63.             $item->expiresAfter($lifeTime);
  64.         }
  65.         return $this->pool->save($item->set($data));
  66.     }
  67.     /**
  68.      * {@inheritdoc}
  69.      */
  70.     protected function doDelete($id)
  71.     {
  72.         return $this->pool->deleteItem(rawurlencode($id));
  73.     }
  74.     /**
  75.      * {@inheritdoc}
  76.      */
  77.     protected function doFlush()
  78.     {
  79.         $this->pool->clear();
  80.     }
  81.     /**
  82.      * {@inheritdoc}
  83.      */
  84.     protected function doGetStats()
  85.     {
  86.     }
  87. }