4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator\Mapping\Cache;
14 use Doctrine\Common\Cache\Cache;
15 use Symfony\Component\Validator\Mapping\ClassMetadata;
18 * Adapts a Doctrine cache to a CacheInterface.
20 * @author Florian Voutzinos <florian@voutzinos.com>
22 final class DoctrineCache implements CacheInterface
26 public function __construct(Cache $cache)
28 $this->cache = $cache;
31 public function setCache(Cache $cache)
33 $this->cache = $cache;
39 public function has($class)
41 return $this->cache->contains($class);
47 public function read($class)
49 return $this->cache->fetch($class);
55 public function write(ClassMetadata $metadata)
57 $this->cache->save($metadata->getClassName(), $metadata);