1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* For the full copyright and license information, please view the LICENSE |
4
|
|
|
* file that was distributed with this source code. |
5
|
|
|
* |
6
|
|
|
* @author Nikita Vershinin <[email protected]> |
7
|
|
|
* @license MIT |
8
|
|
|
*/ |
9
|
|
|
namespace Endeveit\Cache\Drivers; |
10
|
|
|
|
11
|
|
|
use Endeveit\Cache\Interfaces\Driver; |
12
|
|
|
use Endeveit\Cache\Interfaces\Serializer; |
13
|
|
|
use Endeveit\Cache\Serializers\BuiltIn; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* The stub object used only to implement the Driver interfaces. |
17
|
|
|
* @codeCoverageIgnore |
18
|
|
|
*/ |
19
|
|
|
class BlackHole implements Driver |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
* |
25
|
|
|
* @var \Endeveit\Cache\Interfaces\Serializer |
26
|
|
|
*/ |
27
|
|
|
protected $serializer = null; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
* |
32
|
|
|
* @param string $id |
33
|
|
|
* @param integer|null $lockTimeout |
34
|
|
|
* @return mixed|false Data on success, false on failure |
35
|
|
|
*/ |
36
|
|
|
public function load($id, $lockTimeout = null) |
37
|
|
|
{ |
38
|
|
|
return false; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
* |
44
|
|
|
* @param array $identifiers |
45
|
|
|
* @return array |
46
|
|
|
*/ |
47
|
|
|
public function loadMany(array $identifiers) |
48
|
|
|
{ |
49
|
|
|
return array_combine( |
50
|
|
|
$identifiers, |
51
|
|
|
array_fill(0, count($identifiers), false) |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
* |
58
|
|
|
* @param mixed $data |
59
|
|
|
* @param string $id |
60
|
|
|
* @param array $tags |
61
|
|
|
* @param integer|boolean $lifetime |
62
|
|
|
* @return boolean |
63
|
|
|
*/ |
64
|
|
|
public function save($data, $id, array $tags = array(), $lifetime = false) |
65
|
|
|
{ |
66
|
|
|
return true; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
* |
72
|
|
|
* @param string $id |
73
|
|
|
* @return boolean |
74
|
|
|
*/ |
75
|
|
|
public function remove($id) |
76
|
|
|
{ |
77
|
|
|
return true; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* {@inheritdoc} |
82
|
|
|
* |
83
|
|
|
* @param array $tags |
84
|
|
|
* @return boolean |
85
|
|
|
*/ |
86
|
|
|
public function removeByTags(array $tags) |
87
|
|
|
{ |
88
|
|
|
return true; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* {@inheritdoc} |
93
|
|
|
* |
94
|
|
|
* @param string $id |
95
|
|
|
* @param integer $extraLifetime |
96
|
|
|
* @return boolean |
97
|
|
|
*/ |
98
|
|
|
public function touch($id, $extraLifetime) |
99
|
|
|
{ |
100
|
|
|
return true; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* {@inheritdoc} |
105
|
|
|
* |
106
|
|
|
* @param string $id |
107
|
|
|
* @param integer $value |
108
|
|
|
* @return integer |
109
|
|
|
*/ |
110
|
|
|
public function increment($id, $value = 1) |
111
|
|
|
{ |
112
|
|
|
return intval($value); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* {@inheritdoc} |
117
|
|
|
* |
118
|
|
|
* @param string $id |
119
|
|
|
* @param integer $value |
120
|
|
|
* @return integer |
121
|
|
|
*/ |
122
|
|
|
public function decrement($id, $value = 1) |
123
|
|
|
{ |
124
|
|
|
return -intval($value); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* {@inheritdoc} |
129
|
|
|
* |
130
|
|
|
* @param string $id |
131
|
|
|
* @return boolean |
132
|
|
|
*/ |
133
|
|
|
public function contains($id) |
134
|
|
|
{ |
135
|
|
|
return false; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* {@inheritdoc} |
140
|
|
|
* |
141
|
|
|
* @return boolean |
142
|
|
|
*/ |
143
|
|
|
public function flush() |
144
|
|
|
{ |
145
|
|
|
return true; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* {@inheritdoc} |
150
|
|
|
* |
151
|
|
|
* @param \Endeveit\Cache\Interfaces\Serializer $serializer |
152
|
|
|
* @return void |
153
|
|
|
*/ |
154
|
|
|
public function setSerializer(Serializer $serializer) |
155
|
|
|
{ |
156
|
|
|
$this->serializer = $serializer; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* {@inheritdoc} |
161
|
|
|
* |
162
|
|
|
* @return \Endeveit\Cache\Interfaces\Serializer |
163
|
|
|
*/ |
164
|
|
|
public function getSerializer() |
165
|
|
|
{ |
166
|
|
|
if (null === $this->serializer) { |
167
|
|
|
$this->serializer = new BuiltIn(); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
return $this->serializer; |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
|