This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php

74 lines
1.4 KiB
PHP
Raw Normal View History

2016-01-18 14:59:30 +00:00
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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 Doctrine\Common\Cache\CacheProvider;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class DoctrineAdapter extends AbstractAdapter
{
private $provider;
public function __construct(CacheProvider $provider, $defaultLifetime = null)
{
parent::__construct('', $defaultLifetime);
$this->provider = $provider;
}
/**
* {@inheritdoc}
*/
protected function doFetch(array $ids)
{
return $this->provider->fetchMultiple($ids);
}
/**
* {@inheritdoc}
*/
protected function doHave($id)
{
return $this->provider->contains($id);
}
/**
* {@inheritdoc}
*/
protected function doClear($namespace)
2016-01-18 14:59:30 +00:00
{
return $this->provider->flushAll();
}
/**
* {@inheritdoc}
*/
protected function doDelete(array $ids)
{
$ok = true;
foreach ($ids as $id) {
$ok = $this->provider->delete($id) && $ok;
}
return $ok;
}
/**
* {@inheritdoc}
*/
protected function doSave(array $values, $lifetime)
{
return $this->provider->saveMultiple($values, $lifetime);
}
}