You are here

final class DoctrineCache in Plug 7

Adapts a Doctrine cache to a CacheInterface.

@author Florian Voutzinos <florian@voutzinos.com>

Hierarchy

Expanded class hierarchy of DoctrineCache

1 file declares its use of DoctrineCache
DoctrineCacheTest.php in lib/Symfony/validator/Symfony/Component/Validator/Tests/Mapping/Cache/DoctrineCacheTest.php

File

lib/Symfony/validator/Symfony/Component/Validator/Mapping/Cache/DoctrineCache.php, line 22

Namespace

Symfony\Component\Validator\Mapping\Cache
View source
final class DoctrineCache implements CacheInterface {
  private $cache;

  /**
   * Creates a new Doctrine cache.
   *
   * @param Cache $cache The cache to adapt
   */
  public function __construct(Cache $cache) {
    $this->cache = $cache;
  }

  /**
   * Sets the cache to adapt.
   *
   * @param Cache $cache The cache to adapt
   */
  public function setCache(Cache $cache) {
    $this->cache = $cache;
  }

  /**
   * {@inheritdoc}
   */
  public function has($class) {
    return $this->cache
      ->contains($class);
  }

  /**
   * {@inheritdoc}
   */
  public function read($class) {
    return $this->cache
      ->fetch($class);
  }

  /**
   * {@inheritdoc}
   */
  public function write(ClassMetadata $metadata) {
    $this->cache
      ->save($metadata
      ->getClassName(), $metadata);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DoctrineCache::$cache private property
DoctrineCache::has public function Returns whether metadata for the given class exists in the cache. Overrides CacheInterface::has
DoctrineCache::read public function Returns the metadata for the given class from the cache. Overrides CacheInterface::read
DoctrineCache::setCache public function Sets the cache to adapt.
DoctrineCache::write public function Stores a class metadata in the cache. Overrides CacheInterface::write
DoctrineCache::__construct public function Creates a new Doctrine cache.