@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | if ($item instanceof Item) { |
84 | 84 | try { |
85 | 85 | $result = (array) $this->getCollection()->update( |
86 | - ['_id' => $item->getKey()], |
|
87 | - [ |
|
86 | + ['_id' => $item->getKey()], |
|
87 | + [ |
|
88 | 88 | '$set' => [ |
89 | - self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : new MongoDate(time())), |
|
90 | - self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
91 | - self::DRIVER_TAGS_WRAPPER_INDEX => new MongoBinData($this->encode($item->getTags()), MongoBinData::BYTE_ARRAY), |
|
89 | + self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : new MongoDate(time())), |
|
90 | + self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
91 | + self::DRIVER_TAGS_WRAPPER_INDEX => new MongoBinData($this->encode($item->getTags()), MongoBinData::BYTE_ARRAY), |
|
92 | 92 | ], |
93 | - ], |
|
94 | - ['upsert' => true, 'multiple' => false] |
|
93 | + ], |
|
94 | + ['upsert' => true, 'multiple' => false] |
|
95 | 95 | ); |
96 | 96 | } catch (MongoCursorException $e) { |
97 | 97 | return false; |
@@ -110,14 +110,14 @@ discard block |
||
110 | 110 | protected function driverRead(CacheItemInterface $item) |
111 | 111 | { |
112 | 112 | $document = $this->getCollection() |
113 | - ->findOne(['_id' => $item->getKey()], |
|
113 | + ->findOne(['_id' => $item->getKey()], |
|
114 | 114 | [self::DRIVER_DATA_WRAPPER_INDEX, self::DRIVER_EDATE_WRAPPER_INDEX, self::DRIVER_TAGS_WRAPPER_INDEX /*'d', 'e'*/]); |
115 | 115 | |
116 | 116 | if ($document) { |
117 | 117 | return [ |
118 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
119 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->sec), |
|
120 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
118 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
119 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->sec), |
|
120 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
121 | 121 | ]; |
122 | 122 | } else { |
123 | 123 | return null; |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | * @todo make an url builder |
173 | 173 | */ |
174 | 174 | $this->instance = $this->instance ?: (new MongodbClient('mongodb://' . |
175 | - ($username ?: '') . |
|
176 | - ($password ? ":{$password}" : '') . |
|
177 | - ($username ? '@' : '') . "{$host}" . |
|
178 | - ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]))->phpFastCache; |
|
175 | + ($username ?: '') . |
|
176 | + ($password ? ":{$password}" : '') . |
|
177 | + ($username ? '@' : '') . "{$host}" . |
|
178 | + ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]))->phpFastCache; |
|
179 | 179 | // $this->instance->Cache->createIndex([self::DRIVER_TIME_WRAPPER_INDEX => 1], ['expireAfterSeconds' => 0]); |
180 | 180 | } |
181 | 181 | } |
@@ -201,25 +201,25 @@ discard block |
||
201 | 201 | public function getStats() |
202 | 202 | { |
203 | 203 | $serverStatus = $this->getCollection()->db->command([ |
204 | - 'serverStatus' => 1, |
|
205 | - 'recordStats' => 0, |
|
206 | - 'repl' => 0, |
|
207 | - 'metrics' => 0, |
|
204 | + 'serverStatus' => 1, |
|
205 | + 'recordStats' => 0, |
|
206 | + 'repl' => 0, |
|
207 | + 'metrics' => 0, |
|
208 | 208 | ]); |
209 | 209 | |
210 | 210 | $collStats = $this->getCollection()->db->command([ |
211 | - 'collStats' => 'Cache', |
|
212 | - 'verbose' => true, |
|
211 | + 'collStats' => 'Cache', |
|
212 | + 'verbose' => true, |
|
213 | 213 | ]); |
214 | 214 | |
215 | 215 | $stats = (new driverStatistic()) |
216 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
217 | - ->setSize((int) @$collStats[ 'size' ]) |
|
218 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
219 | - ->setRawData([ |
|
216 | + ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
217 | + ->setSize((int) @$collStats[ 'size' ]) |
|
218 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
219 | + ->setRawData([ |
|
220 | 220 | 'serverStatus' => $serverStatus, |
221 | 221 | 'collStats' => $collStats, |
222 | - ]); |
|
222 | + ]); |
|
223 | 223 | |
224 | 224 | return $stats; |
225 | 225 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | /** |
74 | 74 | * @param \Psr\Cache\CacheItemInterface $item |
75 | - * @return mixed |
|
75 | + * @return boolean |
|
76 | 76 | * @throws phpFastCacheInvalidArgumentException |
77 | 77 | */ |
78 | 78 | protected function driverWrite(CacheItemInterface $item) |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
155 | - * @return bool |
|
155 | + * @return boolean|null |
|
156 | 156 | * @throws MongoConnectionException |
157 | 157 | * @throws LogicException |
158 | 158 | */ |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function driverCheck() |
64 | 64 | { |
65 | - if(class_exists('MongoDB\Driver\Manager')){ |
|
65 | + if (class_exists('MongoDB\Driver\Manager')) { |
|
66 | 66 | trigger_error('PhpFastCache currently only support the pecl Mongo extension.<br /> |
67 | 67 | The Support for the MongoDB extension will be added coming soon.', E_USER_ERROR); |
68 | 68 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | return false; |
98 | 98 | } |
99 | 99 | |
100 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
100 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
101 | 101 | } else { |
102 | 102 | throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected'); |
103 | 103 | } |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | |
116 | 116 | if ($document) { |
117 | 117 | return [ |
118 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
119 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->sec), |
|
120 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
118 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->bin), |
|
119 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->sec), |
|
120 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->bin), |
|
121 | 121 | ]; |
122 | 122 | } else { |
123 | 123 | return null; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | if ($item instanceof Item) { |
138 | 138 | $deletionResult = (array) $this->getCollection()->remove(['_id' => $item->getKey()], ["w" => 1]); |
139 | 139 | |
140 | - return (int) $deletionResult[ 'ok' ] === 1 && !$deletionResult[ 'err' ]; |
|
140 | + return (int) $deletionResult['ok'] === 1 && !$deletionResult['err']; |
|
141 | 141 | } else { |
142 | 142 | throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected'); |
143 | 143 | } |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | if ($this->instance instanceof MongodbClient) { |
162 | 162 | throw new LogicException('Already connected to Mongodb server'); |
163 | 163 | } else { |
164 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
165 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : '27017'; |
|
166 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 3; |
|
167 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
168 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
164 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
165 | + $port = isset($this->config['port']) ? $this->config['port'] : '27017'; |
|
166 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 3; |
|
167 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
168 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
169 | 169 | |
170 | 170 | |
171 | 171 | /** |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | ]); |
226 | 226 | |
227 | 227 | $stats = (new driverStatistic()) |
228 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
229 | - ->setSize((int) @$collStats[ 'size' ]) |
|
228 | + ->setInfo('MongoDB version ' . $serverStatus['version'] . ', Uptime (in days): ' . round($serverStatus['uptime'] / 86400, 1) . "\n For more information see RawData.") |
|
229 | + ->setSize((int) @$collStats['size']) |
|
230 | 230 | ->setData(implode(', ', array_keys($this->itemInstances))) |
231 | 231 | ->setRawData([ |
232 | 232 | 'serverStatus' => $serverStatus, |
@@ -159,9 +159,9 @@ |
||
159 | 159 | public function driverPreWrap(ExtendedCacheItemInterface $item) |
160 | 160 | { |
161 | 161 | $wrap = [ |
162 | - self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
163 | - self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
164 | - self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
162 | + self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
163 | + self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
164 | + self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
165 | 165 | ]; |
166 | 166 | |
167 | 167 | if($this->config['itemDetailedDate']){ |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if (is_array($config_name)) { |
53 | 53 | $this->config = array_merge($this->config, $config_name); |
54 | 54 | } else { |
55 | - $this->config[ $config_name ] = $value; |
|
55 | + $this->config[$config_name] = $value; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
165 | 165 | ]; |
166 | 166 | |
167 | - if($this->config['itemDetailedDate']){ |
|
168 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = new \DateTime(); |
|
167 | + if ($this->config['itemDetailedDate']) { |
|
168 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = new \DateTime(); |
|
169 | 169 | /** |
170 | 170 | * If the creation date exists |
171 | 171 | * reuse it else set a new Date |
172 | 172 | */ |
173 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
|
174 | - }else{ |
|
175 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
|
176 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
|
173 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate() ?: new \DateTime(); |
|
174 | + } else { |
|
175 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = null; |
|
176 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = null; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | return $wrap; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function driverUnwrapData(array $wrapper) |
187 | 187 | { |
188 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
188 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function driverUnwrapTags(array $wrapper) |
196 | 196 | { |
197 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
197 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function driverUnwrapEdate(array $wrapper) |
206 | 206 | { |
207 | - return $wrapper[ self::DRIVER_EDATE_WRAPPER_INDEX ]; |
|
207 | + return $wrapper[self::DRIVER_EDATE_WRAPPER_INDEX]; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function driverUnwrapCdate(array $wrapper) |
215 | 215 | { |
216 | - return $wrapper[ self::DRIVER_CDATE_WRAPPER_INDEX ]; |
|
216 | + return $wrapper[self::DRIVER_CDATE_WRAPPER_INDEX]; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function driverUnwrapMdate(array $wrapper) |
225 | 225 | { |
226 | - return $wrapper[ self::DRIVER_MDATE_WRAPPER_INDEX ]; |
|
226 | + return $wrapper[self::DRIVER_MDATE_WRAPPER_INDEX]; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * on tags item, it can leads |
249 | 249 | * to an infinite recursive calls |
250 | 250 | */ |
251 | - if(strpos($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX ) === 0){ |
|
251 | + if (strpos($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX) === 0) { |
|
252 | 252 | throw new \LogicException('Trying to set tag(s) to an Tag item index: ' . $item->getKey()); |
253 | 253 | } |
254 | 254 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | foreach ($tagsItems as $tagsItem) { |
292 | 292 | $data = (array) $tagsItem->get(); |
293 | 293 | |
294 | - unset($data[ $item->getKey() ]); |
|
294 | + unset($data[$item->getKey()]); |
|
295 | 295 | $tagsItem->set($data); |
296 | 296 | |
297 | 297 | /** |
@@ -136,7 +136,7 @@ |
||
136 | 136 | * reuse it else set a new Date |
137 | 137 | */ |
138 | 138 | $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
139 | - }else{ |
|
139 | + } else{ |
|
140 | 140 | $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
141 | 141 | $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
142 | 142 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | return true; |
28 | 28 | } else if (constant($CONSTANT_NAME) !== $driverName) { |
29 | 29 | trigger_error('Memcache collision detected, you used both Memcache and Memcached driver in your script, this may leads to unexpected behaviours', |
30 | - E_USER_WARNING); |
|
30 | + E_USER_WARNING); |
|
31 | 31 | |
32 | 32 | return false; |
33 | 33 | } |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`"); |
163 | 163 | $stm->execute(); |
164 | 164 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
165 | - if (!isset($row[ 'db' ])) { |
|
165 | + if (!isset($row['db'])) { |
|
166 | 166 | $db = 1; |
167 | - } elseif ($row[ 'db' ] <= 1) { |
|
167 | + } elseif ($row['db'] <= 1) { |
|
168 | 168 | $db = 1; |
169 | 169 | } else { |
170 | - $db = $row[ 'db' ]; |
|
170 | + $db = $row['db']; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // check file size |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | ':keyword' => $keyword, |
190 | 190 | ]); |
191 | 191 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
192 | - if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
|
193 | - $db = $row[ 'db' ]; |
|
192 | + if (isset($row['db']) && $row['db'] != '') { |
|
193 | + $db = $row['db']; |
|
194 | 194 | } else { |
195 | 195 | /* |
196 | 196 | * Insert new to Indexing |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | /** |
222 | 222 | * init instant |
223 | 223 | */ |
224 | - if (!isset($this->instance[ $instant ])) { |
|
224 | + if (!isset($this->instance[$instant])) { |
|
225 | 225 | // check DB Files ready or not |
226 | 226 | $createTable = false; |
227 | 227 | if (!file_exists($this->SqliteDir . '/db' . $instant) || $reset == true) { |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | $this->initDB($PDO); |
235 | 235 | } |
236 | 236 | |
237 | - $this->instance[ $instant ] = $PDO; |
|
237 | + $this->instance[$instant] = $PDO; |
|
238 | 238 | unset($PDO); |
239 | 239 | |
240 | 240 | } |
241 | 241 | |
242 | - return $this->instance[ $instant ]; |
|
242 | + return $this->instance[$instant]; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * Check for Cross-Driver type confusion |
254 | 254 | */ |
255 | 255 | if ($item instanceof Item) { |
256 | - $skipExisting = isset($this->config[ 'skipExisting' ]) ? $this->config[ 'skipExisting' ] : false; |
|
256 | + $skipExisting = isset($this->config['skipExisting']) ? $this->config['skipExisting'] : false; |
|
257 | 257 | $toWrite = true; |
258 | 258 | |
259 | 259 | // check in cache first |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - if (isset($row[ 'object' ])) { |
|
333 | - return $this->decode($row[ 'object' ]); |
|
332 | + if (isset($row['object'])) { |
|
333 | + return $this->decode($row['object']); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | return null; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE); |
155 | 155 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
156 | - PDO::ERRMODE_EXCEPTION); |
|
156 | + PDO::ERRMODE_EXCEPTION); |
|
157 | 157 | |
158 | 158 | if ($createTable == true) { |
159 | 159 | $this->initIndexing($PDO); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | // look for keyword |
189 | 189 | $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); |
190 | 190 | $stm->execute([ |
191 | - ':keyword' => $keyword, |
|
191 | + ':keyword' => $keyword, |
|
192 | 192 | ]); |
193 | 193 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
194 | 194 | if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | $db = $this->currentDB; |
201 | 201 | $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); |
202 | 202 | $stm->execute([ |
203 | - ':keyword' => $keyword, |
|
204 | - ':db' => $db, |
|
203 | + ':keyword' => $keyword, |
|
204 | + ':db' => $db, |
|
205 | 205 | ]); |
206 | 206 | } |
207 | 207 | |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | if ($toWrite == true) { |
273 | 273 | try { |
274 | 274 | $stm = $this->getDb($item->getKey()) |
275 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
275 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
276 | 276 | $stm->execute([ |
277 | - ':keyword' => $item->getKey(), |
|
278 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
279 | - ':exp' => time() + $item->getTtl(), |
|
277 | + ':keyword' => $item->getKey(), |
|
278 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
279 | + ':exp' => time() + $item->getTtl(), |
|
280 | 280 | ]); |
281 | 281 | |
282 | 282 | return true; |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | |
285 | 285 | try { |
286 | 286 | $stm = $this->getDb($item->getKey(), true) |
287 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
287 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
288 | 288 | $stm->execute([ |
289 | - ':keyword' => $item->getKey(), |
|
290 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
291 | - ':exp' => time() + $item->getTtl(), |
|
289 | + ':keyword' => $item->getKey(), |
|
290 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
291 | + ':exp' => time() + $item->getTtl(), |
|
292 | 292 | ]); |
293 | 293 | } catch (PDOException $e) { |
294 | 294 | return false; |
@@ -310,20 +310,20 @@ discard block |
||
310 | 310 | { |
311 | 311 | try { |
312 | 312 | $stm = $this->getDb($item->getKey()) |
313 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
313 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
314 | 314 | $stm->execute([ |
315 | - ':keyword' => $item->getKey(), |
|
316 | - ':U' => time(), |
|
315 | + ':keyword' => $item->getKey(), |
|
316 | + ':U' => time(), |
|
317 | 317 | ]); |
318 | 318 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
319 | 319 | |
320 | 320 | } catch (PDOException $e) { |
321 | 321 | try { |
322 | 322 | $stm = $this->getDb($item->getKey(), true) |
323 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
323 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
324 | 324 | $stm->execute([ |
325 | - ':keyword' => $item->getKey(), |
|
326 | - ':U' => time(), |
|
325 | + ':keyword' => $item->getKey(), |
|
326 | + ':U' => time(), |
|
327 | 327 | ]); |
328 | 328 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
329 | 329 | } catch (PDOException $e) { |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | if ($item instanceof Item) { |
352 | 352 | try { |
353 | 353 | $stm = $this->getDb($item->getKey()) |
354 | - //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
355 | - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
354 | + //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
355 | + ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
356 | 356 | |
357 | 357 | return $stm->execute([ |
358 | 358 | // ':id' => $row[ 'id' ], |
359 | - ':keyword' => $item->getKey(), |
|
360 | - ':U' => time(), |
|
359 | + ':keyword' => $item->getKey(), |
|
360 | + ':U' => time(), |
|
361 | 361 | ]); |
362 | 362 | } catch (PDOException $e) { |
363 | 363 | return false; |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
209 | - * @param $keyword |
|
209 | + * @param string $keyword |
|
210 | 210 | * @param bool $reset |
211 | 211 | * @return PDO |
212 | 212 | */ |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | /** |
245 | 245 | * @param \Psr\Cache\CacheItemInterface $item |
246 | - * @return mixed |
|
246 | + * @return boolean |
|
247 | 247 | * @throws phpFastCacheInvalidArgumentException |
248 | 248 | */ |
249 | 249 | protected function driverWrite(CacheItemInterface $item) |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | - * @return int|bool Return size in octet or false if no information available |
|
55 | + * @return string Return size in octet or false if no information available |
|
56 | 56 | */ |
57 | 57 | public function getSize() |
58 | 58 | { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | - * @return mixed |
|
63 | + * @return string |
|
64 | 64 | */ |
65 | 65 | public function getData() |
66 | 66 | { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * @param $info |
|
71 | + * @param string $info |
|
72 | 72 | * @return $this |
73 | 73 | */ |
74 | 74 | public function setInfo($info) |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } else { |
86 | 86 | $item->setHit(true); |
87 | 87 | } |
88 | - }else{ |
|
88 | + } else{ |
|
89 | 89 | $item->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ])); |
90 | 90 | } |
91 | 91 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | { |
230 | 230 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
231 | 231 | $this->itemInstances[ $item->getKey() ] = $item; |
232 | - }else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
232 | + } else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
233 | 233 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
234 | 234 | } |
235 | 235 |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function getItem($key) |
62 | 62 | { |
63 | 63 | if (is_string($key)) { |
64 | - if (preg_match('~([' . preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)){ |
|
64 | + if (preg_match('~([' . preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)) { |
|
65 | 65 | throw new phpFastCacheInvalidArgumentException('Unsupported key character detected: "' . $matches[1] . '". Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers'); |
66 | 66 | } |
67 | 67 | if (!array_key_exists($key, $this->itemInstances)) { |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | $driverArray = $this->driverRead($item); |
77 | 77 | |
78 | 78 | if ($driverArray) { |
79 | - if(!is_array($driverArray)){ |
|
79 | + if (!is_array($driverArray)) { |
|
80 | 80 | throw new phpFastCacheCoreException(sprintf('The driverRead method returned an unexpected variable type: %s', gettype($driverArray))); |
81 | 81 | } |
82 | 82 | $item->set($this->driverUnwrapData($driverArray)); |
83 | 83 | $item->expiresAt($this->driverUnwrapEdate($driverArray)); |
84 | 84 | |
85 | - if($this->config['itemDetailedDate']){ |
|
85 | + if ($this->config['itemDetailedDate']) { |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * If the itemDetailedDate has been |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | } else { |
107 | 107 | $item->setHit(true); |
108 | 108 | } |
109 | - }else{ |
|
110 | - $item->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ])); |
|
109 | + } else { |
|
110 | + $item->expiresAfter(abs((int) $this->getConfig()['defaultTtl'])); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * @param $this ExtendedCacheItemPoolInterface |
121 | 121 | * @param $this ExtendedCacheItemInterface |
122 | 122 | */ |
123 | - $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[ $key ]); |
|
123 | + $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[$key]); |
|
124 | 124 | |
125 | - return $this->itemInstances[ $key ]; |
|
125 | + return $this->itemInstances[$key]; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | public function setItem(CacheItemInterface $item) |
134 | 134 | { |
135 | 135 | if ($this->getClassNamespace() . '\\Item' === get_class($item)) { |
136 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
136 | + $this->itemInstances[$item->getKey()] = $item; |
|
137 | 137 | |
138 | 138 | return $this; |
139 | 139 | } else { |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | $collection = []; |
152 | 152 | foreach ($keys as $key) { |
153 | - $collection[ $key ] = $this->getItem($key); |
|
153 | + $collection[$key] = $this->getItem($key); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | return $collection; |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * @var ExtendedCacheItemInterface $item |
248 | 248 | */ |
249 | 249 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
250 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
251 | - } else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
250 | + $this->itemInstances[$item->getKey()] = $item; |
|
251 | + } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
252 | 252 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
253 | 253 | } |
254 | 254 | |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | public function saveDeferred(CacheItemInterface $item) |
279 | 279 | { |
280 | 280 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
281 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
282 | - }else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
281 | + $this->itemInstances[$item->getKey()] = $item; |
|
282 | + } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
283 | 283 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
284 | 284 | } |
285 | 285 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | */ |
291 | 291 | $this->eventManager->dispatch('CacheSaveDeferredItem', $this, $item); |
292 | 292 | |
293 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
293 | + return $this->deferredList[$item->getKey()] = $item; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | foreach ($this->deferredList as $key => $item) { |
311 | 311 | $result = $this->save($item); |
312 | 312 | if ($return !== false) { |
313 | - unset($this->deferredList[ $key ]); |
|
313 | + unset($this->deferredList[$key]); |
|
314 | 314 | $return = $result; |
315 | 315 | } |
316 | 316 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | /** |
239 | 239 | * @param \Psr\Cache\CacheItemInterface $item |
240 | - * @return mixed |
|
240 | + * @return boolean |
|
241 | 241 | * @throws phpFastCacheInvalidArgumentException |
242 | 242 | * @throws \RuntimeException |
243 | 243 | */ |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
297 | - * @return mixed|null |
|
297 | + * @return boolean |
|
298 | 298 | * @throws phpFastCacheInvalidArgumentException |
299 | 299 | */ |
300 | 300 | public function commit() |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | protected function driverRead(CacheItemInterface $item) |
80 | 80 | { |
81 | 81 | return [ |
82 | - self::DRIVER_DATA_WRAPPER_INDEX => true, |
|
83 | - self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
84 | - self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), |
|
82 | + self::DRIVER_DATA_WRAPPER_INDEX => true, |
|
83 | + self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
84 | + self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), |
|
85 | 85 | ]; |
86 | 86 | } |
87 | 87 | |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | { |
132 | 132 | $stat = new driverStatistic(); |
133 | 133 | $stat->setInfo('[Devtrue] A void info string') |
134 | - ->setSize(0) |
|
135 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
136 | - ->setRawData(true); |
|
134 | + ->setSize(0) |
|
135 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
136 | + ->setRawData(true); |
|
137 | 137 | |
138 | 138 | return $stat; |
139 | 139 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @param \Psr\Cache\CacheItemInterface $item |
57 | - * @return mixed |
|
57 | + * @return boolean |
|
58 | 58 | * @throws phpFastCacheInvalidArgumentException |
59 | 59 | */ |
60 | 60 | protected function driverWrite(CacheItemInterface $item) |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | protected function driverRead(CacheItemInterface $item) |
80 | 80 | { |
81 | 81 | return [ |
82 | - self::DRIVER_DATA_WRAPPER_INDEX => false, |
|
83 | - self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
84 | - self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), |
|
82 | + self::DRIVER_DATA_WRAPPER_INDEX => false, |
|
83 | + self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
84 | + self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), |
|
85 | 85 | ]; |
86 | 86 | } |
87 | 87 | /** |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | { |
131 | 131 | $stat = new driverStatistic(); |
132 | 132 | $stat->setInfo('[Devfalse] A void info string') |
133 | - ->setSize(0) |
|
134 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
135 | - ->setRawData(false); |
|
133 | + ->setSize(0) |
|
134 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
135 | + ->setRawData(false); |
|
136 | 136 | |
137 | 137 | return $stat; |
138 | 138 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @param \Psr\Cache\CacheItemInterface $item |
57 | - * @return mixed |
|
57 | + * @return boolean |
|
58 | 58 | * @throws phpFastCacheInvalidArgumentException |
59 | 59 | */ |
60 | 60 | protected function driverWrite(CacheItemInterface $item) |
@@ -133,8 +133,8 @@ |
||
133 | 133 | $stats = (array) zend_shm_cache_info(); |
134 | 134 | return (new driverStatistic()) |
135 | 135 | ->setData(implode(', ', array_keys($this->namespaces))) |
136 | - ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.",$stats[ 'items_total' ])) |
|
136 | + ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total'])) |
|
137 | 137 | ->setRawData($stats) |
138 | - ->setSize($stats[ 'memory_total' ]); |
|
138 | + ->setSize($stats['memory_total']); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | \ No newline at end of file |