<?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.
*/namespaceSymfony\Component\Validator\Mapping\Cache;
useSymfony\Component\Validator\Mapping\ClassMetadata;
class ApcCacheimplements CacheInterface {
private $prefix;
public function__construct($prefix) {
if (!extension_loaded('apc')) {
thrownew\RuntimeException('Unable to use ApcCache to cache validator mappings as APC is not enabled.');
}
$this->prefix = $prefix;
}
public functionhas($class) {
if (!function_exists('apc_exists')) {
$exists = false;
apc_fetch($this->prefix . $class, $exists);
return$exists;
}
returnapc_exists($this->prefix . $class);
}
public functionread($class) {
returnapc_fetch($this->prefix . $class);
}
public functionwrite(ClassMetadata $metadata) {
apc_store($this->prefix . $metadata
->getClassName(), $metadata);
}
}