-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathApcCache.php
More file actions
55 lines (47 loc) · 1.09 KB
/
Copy pathApcCache.php
File metadata and controls
55 lines (47 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Minime\Annotations\Cache;
use Minime\Annotations\Interfaces\CacheInterface;
/**
* Apc cache storage implementation
*
* @package Minime\Annotations
* @author paolo.fagni@gmail.com
*/
class ApcCache implements CacheInterface
{
/**
* Cached annotations
*
* @var array
*/
protected $annotations = [];
public function getKey($docblock)
{
return 'minime-annotations:' . md5($docblock);
}
public function set($key, array $annotations)
{
if (! apcu_exists($key)) {
apcu_store($key, $annotations);
}
}
public function get($key)
{
if (apcu_exists($key)) {
return apcu_fetch($key);
}
return [];
}
public function clear()
{
$cache = apcu_cache_info();
if ($cache) {
foreach ($cache['cache_list'] as $entry) {
if(isset($entry['info'])
&& strpos($entry['info'], 'minime-annotations:') === 0) {
apcu_delete($entry['info']);
}
}
}
}
}