1 | <?php |
||
10 | class Info implements \ArrayAccess, \IteratorAggregate { |
||
11 | |||
12 | /** |
||
13 | * Cache info data |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $data = array(); |
||
17 | |||
18 | /** |
||
19 | * Constructor |
||
20 | * |
||
21 | * @param array $data |
||
22 | */ |
||
23 | public function __construct(array $data = array()) { |
||
26 | |||
27 | /** |
||
28 | * ArrayAccess offsetExists |
||
29 | * |
||
30 | * @param string $offset |
||
31 | * @return bool |
||
32 | */ |
||
33 | public function offsetExists($offset) { |
||
36 | |||
37 | /** |
||
38 | * ArrayAccess offsetGet |
||
39 | * |
||
40 | * @param string $offset |
||
41 | * @return mixed |
||
42 | */ |
||
43 | public function offsetGet($offset) { |
||
46 | |||
47 | /** |
||
48 | * ArrayAccess offsetSet |
||
49 | * |
||
50 | * @param string $offset |
||
51 | * @param mixed $value |
||
52 | */ |
||
53 | public function offsetSet($offset, $value) { |
||
56 | |||
57 | /** |
||
58 | * ArrayAccess offsetUnset |
||
59 | * |
||
60 | * @param string $offset |
||
61 | */ |
||
62 | public function offsetUnset($offset) { |
||
65 | |||
66 | /** |
||
67 | * IteratorAggregate |
||
68 | * |
||
69 | * @return \ArrayIterator |
||
70 | */ |
||
71 | public function getIterator() { |
||
74 | |||
75 | /** |
||
76 | * Updates timestamp items in cache info |
||
77 | * |
||
78 | * @param string $name |
||
79 | * @param array|string $itemNames |
||
80 | */ |
||
81 | public function touchItem($name, $itemNames = array()) { |
||
89 | |||
90 | /** |
||
91 | * Gets an item from cache info |
||
92 | * |
||
93 | * @param string $name |
||
94 | * @param string $itemName |
||
95 | * @param string $type |
||
96 | * @param string $format |
||
97 | * |
||
98 | * @return string|int|bool |
||
99 | */ |
||
100 | public function getItem($name, $itemName, $type = 'int', $format = 'U') { |
||
113 | |||
114 | /** |
||
115 | * Gets an item value or default if not exists |
||
116 | * |
||
117 | * @param string $name |
||
118 | * @param string $itemName |
||
119 | * @param mixed $default |
||
120 | * |
||
121 | * @return mixed |
||
122 | */ |
||
123 | protected function getItemOrDefault($name, $itemName, $default = null) { |
||
126 | |||
127 | /** |
||
128 | * Sets an item |
||
129 | * |
||
130 | * @param string $name |
||
131 | * @param string $item |
||
132 | * @param mixed $value |
||
133 | */ |
||
134 | public function setItem($name, $item, $value) { |
||
137 | |||
138 | /** |
||
139 | * Inreases an item in cache info |
||
140 | * |
||
141 | * @param string $name |
||
142 | * @param string $itemName |
||
143 | */ |
||
144 | public function increaseItem($name, $itemName) { |
||
147 | |||
148 | /** |
||
149 | * Gets Cache info data |
||
150 | * |
||
151 | * @param $name Cache key |
||
152 | * |
||
153 | * @return array |
||
154 | */ |
||
155 | public function getData($name = '') { |
||
158 | |||
159 | /** |
||
160 | * Gets all cache key names |
||
161 | * |
||
162 | * @return array |
||
163 | */ |
||
164 | public function getKeys() { |
||
167 | |||
168 | /** |
||
169 | * Creates an info item |
||
170 | * |
||
171 | * @param string $name |
||
172 | */ |
||
173 | public function createData($name) { |
||
181 | |||
182 | /** |
||
183 | * Deletes an info item |
||
184 | * |
||
185 | * @param string $name |
||
186 | */ |
||
187 | public function deleteData($name) { |
||
192 | |||
193 | /** |
||
194 | * Appends data to an item |
||
195 | * |
||
196 | * @param string $name |
||
197 | * @param array $data |
||
198 | */ |
||
199 | public function appendData($name, array $data) { |
||
202 | |||
203 | /** |
||
204 | * Sets info data |
||
205 | * |
||
206 | * @param array $data |
||
207 | */ |
||
208 | public function setData(array $data) { |
||
211 | |||
212 | /** |
||
213 | * Gets expiry information |
||
214 | * |
||
215 | * @param string $name Cache name |
||
216 | * @param string $format Date format |
||
217 | * |
||
218 | * @return string |
||
219 | */ |
||
220 | public function getExpiry($name, $format = 'U') { |
||
223 | |||
224 | /** |
||
225 | * Get cache names having the given tags |
||
226 | * |
||
227 | * @param array $tags |
||
228 | * |
||
229 | * @return array |
||
230 | */ |
||
231 | public function filterByTags(array $tags) { |
||
240 | |||
241 | } |
||
242 |