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 @trigger_error('The '.__NAMESPACE__.'\ApcCache class is deprecated since version 2.5 and will be removed in 3.0. Use DoctrineCache with the Doctrine\Common\Cache\ApcCache class instead.', E_USER_DEPRECATED);
16 use Symfony\Component\Validator\Mapping\ClassMetadata;
19 * @deprecated since version 2.5, to be removed in 3.0.
20 * Use DoctrineCache with \Doctrine\Common\Cache\ApcCache instead.
22 class ApcCache implements CacheInterface
26 public function __construct($prefix)
28 if (!extension_loaded('apc')) {
29 throw new \RuntimeException('Unable to use ApcCache to cache validator mappings as APC is not enabled.');
32 $this->prefix = $prefix;
35 public function has($class)
37 if (!function_exists('apc_exists')) {
40 apc_fetch($this->prefix.$class, $exists);
45 return apc_exists($this->prefix.$class);
48 public function read($class)
50 return apc_fetch($this->prefix.$class);
53 public function write(ClassMetadata $metadata)
55 apc_store($this->prefix.$metadata->getClassName(), $metadata);