@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * Set provider in error state |
62 | 62 | * |
63 | - * @param bool $status |
|
63 | + * @param bool $state |
|
64 | 64 | * Current status |
65 | 65 | * |
66 | 66 | * @param string $message |
@@ -85,6 +85,9 @@ discard block |
||
85 | 85 | |
86 | 86 | public function getNamespace(); |
87 | 87 | |
88 | + /** |
|
89 | + * @return \Comodojo\Cache\Traits\NamespaceTrait |
|
90 | + */ |
|
88 | 91 | public function setNamespace($namespace); |
89 | 92 | |
90 | 93 | public function clearNamespace(); |
@@ -174,6 +174,9 @@ |
||
174 | 174 | |
175 | 175 | } |
176 | 176 | |
177 | + /** |
|
178 | + * @param string $mode |
|
179 | + */ |
|
177 | 180 | protected function selectFrom($mode, $key, $default=null) { |
178 | 181 | |
179 | 182 | if ( $this->pick_mode < 5 ) { |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | |
87 | 87 | public function set($key, $value, $ttl = null) { |
88 | 88 | |
89 | - if (iterator_count($this->stack) == 0) return $this->vacuum->set($key, $value, $ttl); |
|
89 | + if ( iterator_count($this->stack) == 0 ) return $this->vacuum->set($key, $value, $ttl); |
|
90 | 90 | |
91 | - if ( $this->align_cache === false && $this->pick_mode < 5) { |
|
91 | + if ( $this->align_cache === false && $this->pick_mode < 5 ) { |
|
92 | 92 | return $this->selectProvider()->set($key, $value, $ttl); |
93 | 93 | } |
94 | 94 | |
95 | 95 | $result = []; |
96 | 96 | |
97 | - foreach ($this->stack as $provider) { |
|
97 | + foreach ( $this->stack as $provider ) { |
|
98 | 98 | |
99 | 99 | $pro = $provider[0]; |
100 | 100 | |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | |
114 | 114 | public function delete($key) { |
115 | 115 | |
116 | - if (iterator_count($this->stack) == 0) return $this->vacuum->delete($key); |
|
116 | + if ( iterator_count($this->stack) == 0 ) return $this->vacuum->delete($key); |
|
117 | 117 | |
118 | - if ( $this->align_cache === false && $this->pick_mode < 5) { |
|
118 | + if ( $this->align_cache === false && $this->pick_mode < 5 ) { |
|
119 | 119 | return $this->selectProvider()->delete($key); |
120 | 120 | } |
121 | 121 | |
122 | 122 | $result = []; |
123 | 123 | |
124 | - foreach ($this->stack as $provider) { |
|
124 | + foreach ( $this->stack as $provider ) { |
|
125 | 125 | |
126 | 126 | $result[] = $provider[0]->delete($key); |
127 | 127 | |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | |
140 | 140 | public function setMultiple($values, $ttl = null) { |
141 | 141 | |
142 | - if (iterator_count($this->stack) == 0) return $this->vacuum->setMultiple($values, $ttl); |
|
142 | + if ( iterator_count($this->stack) == 0 ) return $this->vacuum->setMultiple($values, $ttl); |
|
143 | 143 | |
144 | - if ( $this->align_cache === false && $this->pick_mode < 5) { |
|
144 | + if ( $this->align_cache === false && $this->pick_mode < 5 ) { |
|
145 | 145 | return $this->selectProvider()->setMultiple($values, $ttl); |
146 | 146 | } |
147 | 147 | |
148 | 148 | $result = []; |
149 | 149 | |
150 | - foreach ($this->stack as $provider) { |
|
150 | + foreach ( $this->stack as $provider ) { |
|
151 | 151 | |
152 | 152 | $result[] = $provider[0]->setMultiple($values, $ttl); |
153 | 153 | |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | |
160 | 160 | public function deleteMultiple($keys) { |
161 | 161 | |
162 | - if (iterator_count($this->stack) == 0) return $this->vacuum->deleteMultiple($keys); |
|
162 | + if ( iterator_count($this->stack) == 0 ) return $this->vacuum->deleteMultiple($keys); |
|
163 | 163 | |
164 | - if ( $this->align_cache === false && $this->pick_mode < 5) { |
|
164 | + if ( $this->align_cache === false && $this->pick_mode < 5 ) { |
|
165 | 165 | return $this->selectProvider()->deleteMultiple($keys); |
166 | 166 | } |
167 | 167 | |
168 | 168 | $result = []; |
169 | 169 | |
170 | - foreach ($this->stack as $provider) { |
|
170 | + foreach ( $this->stack as $provider ) { |
|
171 | 171 | |
172 | 172 | $result[] = $provider[0]->deleteMultiple($keys); |
173 | 173 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $manager = new Manager(...$manager_configuration); |
191 | 191 | |
192 | 192 | if ( $enable ) { |
193 | - foreach ($providers as $name => $provider) { |
|
193 | + foreach ( $providers as $name => $provider ) { |
|
194 | 194 | $instance = $provider->instance; |
195 | 195 | $weight = $provider->weight; |
196 | 196 | $id = $instance->getId(); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | } |
205 | 205 | |
206 | - protected function selectFrom($mode, $key, $default=null) { |
|
206 | + protected function selectFrom($mode, $key, $default = null) { |
|
207 | 207 | |
208 | 208 | if ( $this->pick_mode < 5 ) { |
209 | 209 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | $provider = $this->selectProvider(); |
229 | 229 | |
230 | - switch ($mode) { |
|
230 | + switch ( $mode ) { |
|
231 | 231 | |
232 | 232 | case 'GET': |
233 | 233 | $data = $provider->get($key, $default); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | |
254 | 254 | if ( $mode == 'GET' ) { |
255 | 255 | |
256 | - foreach ($this->stack as $provider) { |
|
256 | + foreach ( $this->stack as $provider ) { |
|
257 | 257 | |
258 | 258 | $result[] = $provider[0]->get($key, $default); |
259 | 259 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | |
269 | 269 | } else if ( $mode == 'GETMULTIPLE' ) { |
270 | 270 | |
271 | - foreach ($this->stack as $provider) { |
|
271 | + foreach ( $this->stack as $provider ) { |
|
272 | 272 | |
273 | 273 | $result[] = $provider[0]->getMultiple($key, $default); |
274 | 274 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | |
288 | 288 | } else { |
289 | 289 | |
290 | - foreach ($this->stack as $provider) { |
|
290 | + foreach ( $this->stack as $provider ) { |
|
291 | 291 | |
292 | 292 | $result[] = $provider[0]->has($key); |
293 | 293 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | |
309 | 309 | if ( $mode == 'GET' ) { |
310 | 310 | |
311 | - foreach ($this->stack as $provider) { |
|
311 | + foreach ( $this->stack as $provider ) { |
|
312 | 312 | |
313 | 313 | $item = $provider[0]->get($key); |
314 | 314 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | } else if ( $mode == 'GETMULTIPLE' ) { |
332 | 332 | |
333 | - foreach ($this->stack as $provider) { |
|
333 | + foreach ( $this->stack as $provider ) { |
|
334 | 334 | |
335 | 335 | $items = $provider[0]->getMultiple($key); |
336 | 336 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | |
355 | 355 | } else { |
356 | 356 | |
357 | - foreach ($this->stack as $provider) { |
|
357 | + foreach ( $this->stack as $provider ) { |
|
358 | 358 | |
359 | 359 | $item = $provider[0]->has($key); |
360 | 360 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | /** |
42 | 42 | * {@inheritdoc} |
43 | 43 | */ |
44 | - public function setNamespace($namespace=null) { |
|
44 | + public function setNamespace($namespace = null) { |
|
45 | 45 | |
46 | 46 | if ( empty($namespace) ) { |
47 | 47 |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | |
55 | 55 | public function clear() { |
56 | 56 | |
57 | - if ( $this->align_cache === false && $this->pick_mode < 5) { |
|
57 | + if ( $this->align_cache === false && $this->pick_mode < 5 ) { |
|
58 | 58 | return $this->selectProvider()->clear(); |
59 | 59 | } |
60 | 60 | |
61 | 61 | $result = []; |
62 | 62 | |
63 | - foreach ($this->stack as $provider) { |
|
63 | + foreach ( $this->stack as $provider ) { |
|
64 | 64 | |
65 | 65 | $result[] = $provider[0]->clear(); |
66 | 66 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | public function setNamespace($namespace = null) { |
74 | 74 | |
75 | - foreach ($this->stack->getAll(false) as $provider) { |
|
75 | + foreach ( $this->stack->getAll(false) as $provider ) { |
|
76 | 76 | $provider->setNamespace($namespace); |
77 | 77 | } |
78 | 78 | |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | |
85 | 85 | public function clearNamespace() { |
86 | 86 | |
87 | - if ( $this->align_cache === false && $this->pick_mode < 5) { |
|
87 | + if ( $this->align_cache === false && $this->pick_mode < 5 ) { |
|
88 | 88 | return $this->selectProvider()->clearNamespace(); |
89 | 89 | } |
90 | 90 | |
91 | 91 | $result = []; |
92 | 92 | |
93 | - foreach ($this->stack->getAll() as $provider) { |
|
93 | + foreach ( $this->stack->getAll() as $provider ) { |
|
94 | 94 | $result[] = $provider->clearNamespace(); |
95 | 95 | } |
96 | 96 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | $stats = []; |
104 | 104 | |
105 | - foreach ($this->stack->getAll(false) as $provider) { |
|
105 | + foreach ( $this->stack->getAll(false) as $provider ) { |
|
106 | 106 | $stats[] = $provider->getStats(); |
107 | 107 | } |
108 | 108 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | protected function selectProvider() { |
114 | 114 | |
115 | - switch ($this->pick_mode) { |
|
115 | + switch ( $this->pick_mode ) { |
|
116 | 116 | |
117 | 117 | case 1: |
118 | 118 | $provider = $this->stack->getFirstProvider(); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | $items = []; |
31 | 31 | |
32 | - foreach ($keys as $key) { |
|
32 | + foreach ( $keys as $key ) { |
|
33 | 33 | |
34 | 34 | $items[$key] = $this->getItem($key); |
35 | 35 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $result = []; |
44 | 44 | |
45 | - foreach ($keys as $key) { |
|
45 | + foreach ( $keys as $key ) { |
|
46 | 46 | |
47 | 47 | $result[] = $this->deleteItem($key); |
48 | 48 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | |
71 | 71 | $active_namespace = $this->getNamespace(); |
72 | 72 | |
73 | - foreach ($this->queue as $namespace => $queue) { |
|
73 | + foreach ( $this->queue as $namespace => $queue ) { |
|
74 | 74 | |
75 | 75 | $this->setNamespace($namespace); |
76 | 76 | |
77 | - foreach ($queue as $key => $item) { |
|
77 | + foreach ( $queue as $key => $item ) { |
|
78 | 78 | |
79 | 79 | $result[] = $this->save($item); |
80 | 80 |
@@ -261,11 +261,11 @@ |
||
261 | 261 | |
262 | 262 | $active_namespace = $this->getNamespace(); |
263 | 263 | |
264 | - foreach ($this->queue as $namespace => $queue) { |
|
264 | + foreach ( $this->queue as $namespace => $queue ) { |
|
265 | 265 | |
266 | 266 | $this->setNamespace($namespace); |
267 | 267 | |
268 | - foreach ($queue as $key => $item) { |
|
268 | + foreach ( $queue as $key => $item ) { |
|
269 | 269 | |
270 | 270 | $result[] = $this->save($item); |
271 | 271 |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | |
85 | 85 | if ( $enabled === true ) { |
86 | 86 | |
87 | - foreach($this as $id => $provider) $result[$id] = $provider[0]; |
|
87 | + foreach ( $this as $id => $provider ) $result[$id] = $provider[0]; |
|
88 | 88 | |
89 | 89 | } else { |
90 | 90 | |
91 | - foreach($this->getInnerIterator() as $id => $provider) $result[$id] = $provider[0]; |
|
91 | + foreach ( $this->getInnerIterator() as $id => $provider ) $result[$id] = $provider[0]; |
|
92 | 92 | |
93 | 93 | } |
94 | 94 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | $result = []; |
167 | 167 | |
168 | - foreach($this as $id => $provider) $result[$id] = $provider[1]; |
|
168 | + foreach ( $this as $id => $provider ) $result[$id] = $provider[1]; |
|
169 | 169 | |
170 | 170 | return $result; |
171 | 171 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | if ( $ttl == null || $ttl == 0 ) { |
66 | 66 | $ttl = 0; |
67 | 67 | } else { |
68 | - $ttl = time()+intval($ttl); |
|
68 | + $ttl = time() + intval($ttl); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $cached = @file_put_contents($cacheFile, $value, LOCK_EX); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $result = []; |
126 | 126 | |
127 | - foreach ($keys as $key) { |
|
127 | + foreach ( $keys as $key ) { |
|
128 | 128 | $result[$key] = $this->get($key, $namespace); |
129 | 129 | } |
130 | 130 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | $result = []; |
138 | 138 | |
139 | - foreach ($key_values as $key => $value) { |
|
139 | + foreach ( $key_values as $key => $value ) { |
|
140 | 140 | $result[] = $this->set($key, $namespace, $value, $ttl); |
141 | 141 | } |
142 | 142 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | $result = []; |
150 | 150 | |
151 | - foreach ($keys as $key) { |
|
151 | + foreach ( $keys as $key ) { |
|
152 | 152 | $result[] = $this->delete($key, $namespace); |
153 | 153 | } |
154 | 154 |
@@ -66,7 +66,7 @@ |
||
66 | 66 | if ( $ttl == null || $ttl == 0 ) { |
67 | 67 | $ttl = 0; |
68 | 68 | } else { |
69 | - $ttl = time()+intval($ttl); |
|
69 | + $ttl = time() + intval($ttl); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $cached = @file_put_contents($cacheFile, $value, LOCK_EX); |