|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Drupal\controller_annotations\Cache; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Cache\Cache; |
|
6
|
|
|
use Doctrine\Common\Cache\CacheProvider; |
|
7
|
|
|
use Drupal\Core\Cache\CacheBackendInterface; |
|
8
|
|
|
|
|
9
|
|
|
class DrupalCache extends CacheProvider |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var CacheBackendInterface |
|
13
|
|
|
*/ |
|
14
|
|
|
private $cache; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @param CacheBackendInterface $cache |
|
18
|
|
|
*/ |
|
19
|
5 |
|
public function __construct(CacheBackendInterface $cache) |
|
20
|
|
|
{ |
|
21
|
5 |
|
$this->cache = $cache; |
|
22
|
5 |
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @inheritdoc |
|
26
|
|
|
*/ |
|
27
|
5 |
|
protected function doFetch($id) |
|
28
|
|
|
{ |
|
29
|
5 |
|
return $this->cache->get($id); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @inheritdoc |
|
34
|
|
|
*/ |
|
35
|
|
|
protected function doContains($id) |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->fetch($id) !== false; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @inheritdoc |
|
42
|
|
|
*/ |
|
43
|
5 |
|
protected function doSave($id, $data, $lifeTime = 0) |
|
44
|
|
|
{ |
|
45
|
5 |
|
$this->cache->set($id, $data, time() + $lifeTime); |
|
46
|
5 |
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @inheritdoc |
|
50
|
|
|
*/ |
|
51
|
|
|
protected function doDelete($id) |
|
52
|
|
|
{ |
|
53
|
|
|
$this->cache->delete($id); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @inheritdoc |
|
58
|
|
|
*/ |
|
59
|
|
|
protected function doFlush() |
|
60
|
|
|
{ |
|
61
|
|
|
$this->cache->deleteAll(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @inheritdoc |
|
66
|
|
|
*/ |
|
67
|
|
|
protected function doGetStats() |
|
68
|
|
|
{ |
|
69
|
|
|
return array( |
|
70
|
|
|
Cache::STATS_HITS => null, |
|
71
|
|
|
Cache::STATS_MISSES => null, |
|
72
|
|
|
Cache::STATS_UPTIME => null, |
|
73
|
|
|
Cache::STATS_MEMORY_USAGE => null, |
|
74
|
|
|
Cache::STATS_MEMORY_AVAILABLE => null, |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|