@@ -16,7 +16,7 @@ |
||
16 | 16 | * @param $className |
17 | 17 | */ |
18 | 18 | spl_autoload_register( |
19 | - function ($className) { |
|
19 | + function($className) { |
|
20 | 20 | if (strpos($className, 'O2System\Cache\\') === false) { |
21 | 21 | return; |
22 | 22 | } |
@@ -29,9 +29,9 @@ |
||
29 | 29 | */ |
30 | 30 | public function __construct(array $config) |
31 | 31 | { |
32 | - if (isset($config[ 'default' ])) { |
|
32 | + if (isset($config['default'])) { |
|
33 | 33 | foreach ($config as $poolOffset => $poolConfig) { |
34 | - $config[ $poolOffset ] = new self($poolConfig); |
|
34 | + $config[$poolOffset] = new self($poolConfig); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | $allItems = $this->memcached->getAllKeys(); |
58 | 58 | |
59 | 59 | foreach ($allItems as $server => $metadata) { |
60 | - foreach ($metadata[ 'items' ] AS $itemKey => $itemMetadata) { |
|
60 | + foreach ($metadata['items'] AS $itemKey => $itemMetadata) { |
|
61 | 61 | $cacheDump = $this->memcached->getExtendedStats('cachedump', (int)$itemKey); |
62 | 62 | |
63 | - foreach ($cacheDump[ $server ] AS $cacheDumpItemKey => $cacheDumpItemMetadata) { |
|
63 | + foreach ($cacheDump[$server] AS $cacheDumpItemKey => $cacheDumpItemMetadata) { |
|
64 | 64 | $items[] = $this->getItem(str_replace($this->prefixKey, '', $cacheDumpItemKey)); |
65 | 65 | } |
66 | 66 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | $metadata = $this->memcached->get($this->prefixKey . $key); |
104 | - $metadata = isset($metadata[ 0 ]) ? $metadata[ 0 ] : $metadata; |
|
104 | + $metadata = isset($metadata[0]) ? $metadata[0] : $metadata; |
|
105 | 105 | |
106 | 106 | return new Item($key, $metadata); |
107 | 107 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | $keys = array_map( |
204 | - function ($key) { |
|
204 | + function($key) { |
|
205 | 205 | return $this->prefixKey . $key; |
206 | 206 | }, |
207 | 207 | $keys |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | public function save(CacheItemInterface $item) |
227 | 227 | { |
228 | 228 | $metadata = $item->getMetadata(); |
229 | - $metadata[ 'data' ] = $item->get(); |
|
229 | + $metadata['data'] = $item->get(); |
|
230 | 230 | |
231 | - return $this->memcached->set($this->prefixKey . $item->getKey(), $metadata, $metadata[ 'ttl' ]); |
|
231 | + return $this->memcached->set($this->prefixKey . $item->getKey(), $metadata, $metadata['ttl']); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | \ No newline at end of file |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | 'weight' => 1, |
106 | 106 | ]; |
107 | 107 | |
108 | - $this->memcached->addserver($this->config[ 'host' ], $this->config[ 'port' ]); |
|
109 | - } elseif (isset($config[ 'servers' ])) { |
|
110 | - foreach ($config[ 'servers' ] as $server) { |
|
111 | - $this->config[ $server[ 'host' ] ] = array_merge( |
|
108 | + $this->memcached->addserver($this->config['host'], $this->config['port']); |
|
109 | + } elseif (isset($config['servers'])) { |
|
110 | + foreach ($config['servers'] as $server) { |
|
111 | + $this->config[$server['host']] = array_merge( |
|
112 | 112 | [ |
113 | 113 | 'host' => '127.0.0.1', |
114 | 114 | 'port' => 11211, |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | ); |
119 | 119 | |
120 | 120 | if (array_key_exists('status', $server)) { |
121 | - if ($server[ 'status' ] === false) { |
|
122 | - $this->config[ $server[ 'host' ] ][ 'retryInterval' ] = -1; |
|
121 | + if ($server['status'] === false) { |
|
122 | + $this->config[$server['host']]['retryInterval'] = -1; |
|
123 | 123 | |
124 | 124 | $this->memcached->addserver( |
125 | - $this->config[ $server[ 'host' ] ][ 'host' ], |
|
126 | - $this->config[ $server[ 'host' ] ][ 'port' ], |
|
127 | - $this->config[ $server[ 'host' ] ][ 'weight' ] |
|
125 | + $this->config[$server['host']]['host'], |
|
126 | + $this->config[$server['host']]['port'], |
|
127 | + $this->config[$server['host']]['weight'] |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | continue; |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | $this->memcached->addserver( |
135 | - $this->config[ $server[ 'host' ] ][ 'host' ], |
|
136 | - $this->config[ $server[ 'host' ] ][ 'port' ], |
|
137 | - $this->config[ $server[ 'host' ] ][ 'weight' ] |
|
135 | + $this->config[$server['host']]['host'], |
|
136 | + $this->config[$server['host']]['port'], |
|
137 | + $this->config[$server['host']]['weight'] |
|
138 | 138 | ); |
139 | 139 | } |
140 | 140 | } else { |
@@ -147,25 +147,25 @@ discard block |
||
147 | 147 | $config |
148 | 148 | ); |
149 | 149 | |
150 | - if (isset($this->config[ 'status' ])) { |
|
151 | - if ($this->config[ 'status' ] === false) { |
|
150 | + if (isset($this->config['status'])) { |
|
151 | + if ($this->config['status'] === false) { |
|
152 | 152 | $this->memcached->addserver( |
153 | - $this->config[ 'host' ], |
|
154 | - $this->config[ 'port' ], |
|
155 | - $this->config[ 'weight' ] |
|
153 | + $this->config['host'], |
|
154 | + $this->config['port'], |
|
155 | + $this->config['weight'] |
|
156 | 156 | ); |
157 | 157 | } else { |
158 | 158 | $this->memcached->addserver( |
159 | - $this->config[ 'host' ], |
|
160 | - $this->config[ 'port' ], |
|
161 | - $this->config[ 'weight' ] |
|
159 | + $this->config['host'], |
|
160 | + $this->config['port'], |
|
161 | + $this->config['weight'] |
|
162 | 162 | ); |
163 | 163 | } |
164 | 164 | } else { |
165 | 165 | $this->memcached->addserver( |
166 | - $this->config[ 'host' ], |
|
167 | - $this->config[ 'port' ], |
|
168 | - $this->config[ 'weight' ] |
|
166 | + $this->config['host'], |
|
167 | + $this->config['port'], |
|
168 | + $this->config['weight'] |
|
169 | 169 | ); |
170 | 170 | } |
171 | 171 | } |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | $allItems = $this->memcache->getExtendedStats('items'); |
58 | 58 | |
59 | 59 | foreach ($allItems as $server => $metadata) { |
60 | - foreach ($metadata[ 'items' ] AS $itemKey => $itemMetadata) { |
|
60 | + foreach ($metadata['items'] AS $itemKey => $itemMetadata) { |
|
61 | 61 | $cacheDump = $this->memcache->getExtendedStats('cachedump', (int)$itemKey); |
62 | 62 | |
63 | - foreach ($cacheDump[ $server ] AS $cacheDumpItemKey => $cacheDumpItemMetadata) { |
|
63 | + foreach ($cacheDump[$server] AS $cacheDumpItemKey => $cacheDumpItemMetadata) { |
|
64 | 64 | $items[] = $this->getItem(str_replace($this->prefixKey, '', $cacheDumpItemKey)); |
65 | 65 | } |
66 | 66 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | $metadata = $this->memcache->get($this->prefixKey . $key); |
104 | - $metadata = isset($metadata[ 0 ]) ? $metadata[ 0 ] : $metadata; |
|
104 | + $metadata = isset($metadata[0]) ? $metadata[0] : $metadata; |
|
105 | 105 | |
106 | 106 | return new Item($key, $metadata); |
107 | 107 | } |
@@ -193,17 +193,17 @@ discard block |
||
193 | 193 | public function save(CacheItemInterface $item) |
194 | 194 | { |
195 | 195 | $metadata = $item->getMetadata(); |
196 | - $metadata[ 'data' ] = $item->get(); |
|
196 | + $metadata['data'] = $item->get(); |
|
197 | 197 | |
198 | 198 | if (extension_loaded('zlib')) { |
199 | 199 | return $this->memcache->set( |
200 | 200 | $this->prefixKey . $item->getKey(), |
201 | 201 | $metadata, |
202 | 202 | MEMCACHE_COMPRESSED, |
203 | - $metadata[ 'ttl' ] |
|
203 | + $metadata['ttl'] |
|
204 | 204 | ); |
205 | 205 | } else { |
206 | - return $this->memcache->set($this->prefixKey . $item->getKey(), $metadata, 0, $metadata[ 'ttl' ]); |
|
206 | + return $this->memcache->set($this->prefixKey . $item->getKey(), $metadata, 0, $metadata['ttl']); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | } |
210 | 210 | \ No newline at end of file |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | 'weight' => 1, |
108 | 108 | ]; |
109 | 109 | |
110 | - $this->memcache->addserver($this->config[ 'host' ], $this->config[ 'port' ]); |
|
111 | - } elseif (isset($config[ 'servers' ])) { |
|
112 | - foreach ($config[ 'servers' ] as $server) { |
|
113 | - $this->config[ $server[ 'host' ] ] = array_merge( |
|
110 | + $this->memcache->addserver($this->config['host'], $this->config['port']); |
|
111 | + } elseif (isset($config['servers'])) { |
|
112 | + foreach ($config['servers'] as $server) { |
|
113 | + $this->config[$server['host']] = array_merge( |
|
114 | 114 | [ |
115 | 115 | 'host' => '127.0.0.1', |
116 | 116 | 'port' => 11211, |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | ); |
123 | 123 | |
124 | 124 | if (array_key_exists('status', $server)) { |
125 | - if ($server[ 'status' ] === false) { |
|
126 | - $this->config[ $server[ 'host' ] ][ 'retryInterval' ] = -1; |
|
125 | + if ($server['status'] === false) { |
|
126 | + $this->config[$server['host']]['retryInterval'] = -1; |
|
127 | 127 | |
128 | 128 | $this->memcache->addserver( |
129 | - $this->config[ $server[ 'host' ] ][ 'host' ], |
|
130 | - $this->config[ $server[ 'host' ] ][ 'port' ], |
|
131 | - $this->config[ $server[ 'host' ] ][ 'persistent' ], |
|
132 | - $this->config[ $server[ 'host' ] ][ 'weight' ], |
|
133 | - $this->config[ $server[ 'host' ] ][ 'timeout' ], |
|
134 | - $this->config[ $server[ 'host' ] ][ 'retryInterval' ], |
|
129 | + $this->config[$server['host']]['host'], |
|
130 | + $this->config[$server['host']]['port'], |
|
131 | + $this->config[$server['host']]['persistent'], |
|
132 | + $this->config[$server['host']]['weight'], |
|
133 | + $this->config[$server['host']]['timeout'], |
|
134 | + $this->config[$server['host']]['retryInterval'], |
|
135 | 135 | false |
136 | 136 | ); |
137 | 137 | |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | $this->memcache->addserver( |
143 | - $this->config[ $server[ 'host' ] ][ 'host' ], |
|
144 | - $this->config[ $server[ 'host' ] ][ 'port' ], |
|
145 | - $this->config[ $server[ 'host' ] ][ 'persistent' ], |
|
146 | - $this->config[ $server[ 'host' ] ][ 'weight' ], |
|
147 | - $this->config[ $server[ 'host' ] ][ 'timeout' ] |
|
143 | + $this->config[$server['host']]['host'], |
|
144 | + $this->config[$server['host']]['port'], |
|
145 | + $this->config[$server['host']]['persistent'], |
|
146 | + $this->config[$server['host']]['weight'], |
|
147 | + $this->config[$server['host']]['timeout'] |
|
148 | 148 | ); |
149 | 149 | } |
150 | 150 | } else { |
@@ -159,33 +159,33 @@ discard block |
||
159 | 159 | $config |
160 | 160 | ); |
161 | 161 | |
162 | - if (isset($this->config[ 'status' ])) { |
|
163 | - if ($this->config[ 'status' ] === false) { |
|
162 | + if (isset($this->config['status'])) { |
|
163 | + if ($this->config['status'] === false) { |
|
164 | 164 | $this->memcache->addserver( |
165 | - $this->config[ 'host' ], |
|
166 | - $this->config[ 'port' ], |
|
167 | - $this->config[ 'persistent' ], |
|
168 | - $this->config[ 'weight' ], |
|
169 | - $this->config[ 'timeout' ], |
|
165 | + $this->config['host'], |
|
166 | + $this->config['port'], |
|
167 | + $this->config['persistent'], |
|
168 | + $this->config['weight'], |
|
169 | + $this->config['timeout'], |
|
170 | 170 | -1, |
171 | 171 | false |
172 | 172 | ); |
173 | 173 | } else { |
174 | 174 | $this->memcache->addserver( |
175 | - $this->config[ 'host' ], |
|
176 | - $this->config[ 'port' ], |
|
177 | - $this->config[ 'persistent' ], |
|
178 | - $this->config[ 'weight' ], |
|
179 | - $this->config[ 'timeout' ] |
|
175 | + $this->config['host'], |
|
176 | + $this->config['port'], |
|
177 | + $this->config['persistent'], |
|
178 | + $this->config['weight'], |
|
179 | + $this->config['timeout'] |
|
180 | 180 | ); |
181 | 181 | } |
182 | 182 | } else { |
183 | 183 | $this->memcache->addserver( |
184 | - $this->config[ 'host' ], |
|
185 | - $this->config[ 'port' ], |
|
186 | - $this->config[ 'persistent' ], |
|
187 | - $this->config[ 'weight' ], |
|
188 | - $this->config[ 'timeout' ] |
|
184 | + $this->config['host'], |
|
185 | + $this->config['port'], |
|
186 | + $this->config['persistent'], |
|
187 | + $this->config['weight'], |
|
188 | + $this->config['timeout'] |
|
189 | 189 | ); |
190 | 190 | } |
191 | 191 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | if (is_file($filename)) { |
107 | 107 | $metadata = unserialize(file_get_contents($filename)); |
108 | 108 | |
109 | - if ($metadata[ 'ttl' ] > 0 AND time() > $metadata[ 'ctime' ] + $metadata[ 'ttl' ]) { |
|
109 | + if ($metadata['ttl'] > 0 AND time() > $metadata['ctime'] + $metadata['ttl']) { |
|
110 | 110 | unlink($filename); |
111 | 111 | } |
112 | 112 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | public function save(CacheItemInterface $item) |
230 | 230 | { |
231 | 231 | $metadata = $item->getMetadata(); |
232 | - $metadata[ 'data' ] = $item->get(); |
|
232 | + $metadata['data'] = $item->get(); |
|
233 | 233 | $metadata = serialize($metadata); |
234 | 234 | |
235 | 235 | $path = $this->path . $this->prefixKey . $item->getKey() . '.cache'; |
@@ -76,19 +76,19 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function connect(array $config) |
78 | 78 | { |
79 | - if (isset($config[ 'path' ])) { |
|
80 | - $config[ 'path' ] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $config[ 'path' ]); |
|
79 | + if (isset($config['path'])) { |
|
80 | + $config['path'] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $config['path']); |
|
81 | 81 | |
82 | - if (is_dir($config[ 'path' ])) { |
|
83 | - $this->path = $config[ 'path' ]; |
|
82 | + if (is_dir($config['path'])) { |
|
83 | + $this->path = $config['path']; |
|
84 | 84 | } elseif (defined('PATH_CACHE')) { |
85 | - if (is_dir($config[ 'path' ])) { |
|
86 | - $this->path = $config[ 'path' ]; |
|
85 | + if (is_dir($config['path'])) { |
|
86 | + $this->path = $config['path']; |
|
87 | 87 | } else { |
88 | - $this->path = PATH_CACHE . str_replace(PATH_CACHE, '', $config[ 'path' ]); |
|
88 | + $this->path = PATH_CACHE . str_replace(PATH_CACHE, '', $config['path']); |
|
89 | 89 | } |
90 | 90 | } else { |
91 | - $this->path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $config[ 'path' ]; |
|
91 | + $this->path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $config['path']; |
|
92 | 92 | } |
93 | 93 | } elseif (defined('PATH_CACHE')) { |
94 | 94 | $this->path = PATH_CACHE; |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | |
247 | 247 | $cacheIterator = new \RegexIterator($directory, '/^.+\.cache/i', \RecursiveRegexIterator::GET_MATCH); |
248 | 248 | |
249 | - $stats[ 'path' ] = $this->path; |
|
250 | - $stats[ 'files' ] = 0; |
|
251 | - $stats[ 'size' ] = 0; |
|
249 | + $stats['path'] = $this->path; |
|
250 | + $stats['files'] = 0; |
|
251 | + $stats['size'] = 0; |
|
252 | 252 | |
253 | 253 | foreach ($cacheIterator as $cacheFiles) { |
254 | 254 | foreach ($cacheFiles as $cacheFile) { |
255 | - $stats[ 'files' ]++; |
|
256 | - $stats[ 'size' ] += filesize($cacheFile); |
|
255 | + $stats['files']++; |
|
256 | + $stats['size'] += filesize($cacheFile); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $apcIterator = new \APCIterator('user'); |
58 | 58 | |
59 | 59 | foreach ($apcIterator as $item) { |
60 | - $items[] = new Item(str_replace($this->prefixKey, '', $item[ 'key' ]), $item[ 'value' ]); |
|
60 | + $items[] = new Item(str_replace($this->prefixKey, '', $item['key']), $item['value']); |
|
61 | 61 | } |
62 | 62 | } elseif (count($keys)) { |
63 | 63 | foreach ($keys as $key) { |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | public function save(CacheItemInterface $item) |
189 | 189 | { |
190 | 190 | $metadata = $item->getMetadata(); |
191 | - $metadata[ 'data' ] = $item->get(); |
|
191 | + $metadata['data'] = $item->get(); |
|
192 | 192 | |
193 | - return apc_store($this->prefixKey . $item->getKey(), $metadata, $metadata[ 'ttl' ]); |
|
193 | + return apc_store($this->prefixKey . $item->getKey(), $metadata, $metadata['ttl']); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | \ No newline at end of file |