db backup prior to drupal security update
[yaffs-website] / vendor / symfony / validator / Mapping / Cache / ApcCache.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Validator\Mapping\Cache;
13
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);
15
16 use Symfony\Component\Validator\Mapping\ClassMetadata;
17
18 /**
19  * @deprecated since version 2.5, to be removed in 3.0.
20  *             Use DoctrineCache with \Doctrine\Common\Cache\ApcCache instead.
21  */
22 class ApcCache implements CacheInterface
23 {
24     private $prefix;
25
26     public function __construct($prefix)
27     {
28         if (!extension_loaded('apc')) {
29             throw new \RuntimeException('Unable to use ApcCache to cache validator mappings as APC is not enabled.');
30         }
31
32         $this->prefix = $prefix;
33     }
34
35     public function has($class)
36     {
37         if (!function_exists('apc_exists')) {
38             $exists = false;
39
40             apc_fetch($this->prefix.$class, $exists);
41
42             return $exists;
43         }
44
45         return apc_exists($this->prefix.$class);
46     }
47
48     public function read($class)
49     {
50         return apc_fetch($this->prefix.$class);
51     }
52
53     public function write(ClassMetadata $metadata)
54     {
55         apc_store($this->prefix.$metadata->getClassName(), $metadata);
56     }
57 }