@@ -20,7 +20,6 @@ discard block |
||
| 20 | 20 | trait PathSeekerTrait |
| 21 | 21 | { |
| 22 | 22 | /** |
| 23 | - * @param bool $skip_create_path |
|
| 24 | 23 | * @param $config |
| 25 | 24 | * @return string |
| 26 | 25 | * @throws \Exception |
@@ -155,7 +154,7 @@ discard block |
||
| 155 | 154 | |
| 156 | 155 | /** |
| 157 | 156 | * @param $filename |
| 158 | - * @return mixed |
|
| 157 | + * @return string |
|
| 159 | 158 | */ |
| 160 | 159 | protected static function cleanFileName($filename) |
| 161 | 160 | { |
@@ -170,7 +169,7 @@ discard block |
||
| 170 | 169 | } |
| 171 | 170 | |
| 172 | 171 | /** |
| 173 | - * @param $path |
|
| 172 | + * @param string $path |
|
| 174 | 173 | * @param bool $create |
| 175 | 174 | * @throws \Exception |
| 176 | 175 | */ |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | protected static function cleanFileName($filename) |
| 161 | 161 | { |
| 162 | 162 | $regex = [ |
| 163 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 164 | - '/\.$/', |
|
| 165 | - '/^\./', |
|
| 163 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 164 | + '/\.$/', |
|
| 165 | + '/^\./', |
|
| 166 | 166 | ]; |
| 167 | 167 | $replace = ['-', '', '']; |
| 168 | 168 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | chmod($path, 0777); |
| 183 | 183 | } catch (phpFastCacheDriverException $e) { |
| 184 | 184 | throw new phpFastCacheDriverException('PLEASE CHMOD ' . $path . ' - 0777 OR ANY WRITABLE PERMISSION!', |
| 185 | - 92); |
|
| 185 | + 92); |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
@@ -29,27 +29,27 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | $tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(); |
| 31 | 31 | |
| 32 | - if (!isset($this->config[ 'path' ]) || $this->config[ 'path' ] == '') { |
|
| 32 | + if (!isset($this->config['path']) || $this->config['path'] == '') { |
|
| 33 | 33 | if (self::isPHPModule()) { |
| 34 | 34 | $path = $tmp_dir; |
| 35 | 35 | } else { |
| 36 | - $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../'; |
|
| 37 | - $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . '/'; |
|
| 36 | + $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../'; |
|
| 37 | + $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . '/'; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if ($this->config[ 'path' ] != '') { |
|
| 41 | - $path = $this->config[ 'path' ]; |
|
| 40 | + if ($this->config['path'] != '') { |
|
| 41 | + $path = $this->config['path']; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | } else { |
| 45 | - $path = $this->config[ 'path' ]; |
|
| 45 | + $path = $this->config['path']; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
| 48 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
| 49 | 49 | if ($securityKey == "" || $securityKey == 'auto') { |
| 50 | - $securityKey = $this->config[ 'securityKey' ]; |
|
| 50 | + $securityKey = $this->config['securityKey']; |
|
| 51 | 51 | if ($securityKey == 'auto' || $securityKey == '') { |
| 52 | - $securityKey = isset($_SERVER[ 'HTTP_HOST' ]) ? preg_replace('/^www./', '', strtolower($_SERVER[ 'HTTP_HOST' ])) : "default"; |
|
| 52 | + $securityKey = isset($_SERVER['HTTP_HOST']) ? preg_replace('/^www./', '', strtolower($_SERVER['HTTP_HOST'])) : "default"; |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | if ($securityKey != '') { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $full_pathx = md5($full_path); |
| 63 | 63 | |
| 64 | 64 | |
| 65 | - if (!isset($this->tmp[ $full_pathx ])) { |
|
| 65 | + if (!isset($this->tmp[$full_pathx])) { |
|
| 66 | 66 | |
| 67 | 67 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
| 68 | 68 | if (!@file_exists($full_path)) { |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - $this->tmp[ $full_pathx ] = true; |
|
| 90 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
| 89 | + $this->tmp[$full_pathx] = true; |
|
| 90 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | return realpath($full_path); |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function setChmodAuto() |
| 148 | 148 | { |
| 149 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
| 149 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
| 150 | 150 | return 0777; |
| 151 | 151 | } else { |
| 152 | - return $this->config[ 'default_chmod' ]; |
|
| 152 | + return $this->config['default_chmod']; |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * @param \Psr\Cache\CacheItemInterface $item |
| 160 | - * @return mixed |
|
| 160 | + * @return boolean |
|
| 161 | 161 | * @throws \InvalidArgumentException |
| 162 | 162 | */ |
| 163 | 163 | public function save(CacheItemInterface $item) |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | - * @return mixed|null |
|
| 178 | + * @return boolean |
|
| 179 | 179 | * @throws \InvalidArgumentException |
| 180 | 180 | */ |
| 181 | 181 | public function commit() |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key))); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - return $this->itemInstances[ $key ]; |
|
| 74 | + return $this->itemInstances[$key]; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public function setItem(CacheItemInterface $item) |
| 83 | 83 | { |
| 84 | 84 | if ($this->getClassNamespace() . '\\Item' === get_class($item)) { |
| 85 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
| 85 | + $this->itemInstances[$item->getKey()] = $item; |
|
| 86 | 86 | |
| 87 | 87 | return $this; |
| 88 | 88 | } else { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $collection = []; |
| 101 | 101 | foreach ($keys as $key) { |
| 102 | - $collection[ $key ] = $this->getItem($key); |
|
| 102 | + $collection[$key] = $this->getItem($key); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | return $collection; |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function saveDeferred(CacheItemInterface $item) |
| 173 | 173 | { |
| 174 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
| 174 | + return $this->deferredList[$item->getKey()] = $item; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | foreach ($this->deferredList as $key => $item) { |
| 185 | 185 | $result = $this->save($item); |
| 186 | 186 | if ($return !== false) { |
| 187 | - unset($this->deferredList[ $key ]); |
|
| 187 | + unset($this->deferredList[$key]); |
|
| 188 | 188 | $return = $result; |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -128,7 +128,7 @@ |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | - * @return bool |
|
| 131 | + * @return boolean|null |
|
| 132 | 132 | */ |
| 133 | 133 | public function driverConnect() |
| 134 | 134 | { |
@@ -142,10 +142,10 @@ |
||
| 142 | 142 | $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
| 143 | 143 | $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
| 144 | 144 | $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
| 145 | - [ |
|
| 145 | + [ |
|
| 146 | 146 | 'bucket' => 'default', |
| 147 | 147 | 'password' => '', |
| 148 | - ], |
|
| 148 | + ], |
|
| 149 | 149 | ]; |
| 150 | 150 | |
| 151 | 151 | $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password); |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | } else { |
| 138 | 138 | |
| 139 | 139 | |
| 140 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 140 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 141 | 141 | //$port = isset($server[ 'port' ]) ? $server[ 'port' ] : '11211'; |
| 142 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 143 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 144 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
| 142 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 143 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 144 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
| 145 | 145 | [ |
| 146 | 146 | 'bucket' => 'default', |
| 147 | 147 | 'password' => '', |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | |
| 154 | 154 | foreach ($buckets as $bucket) { |
| 155 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
| 156 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
| 155 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
| 156 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | protected function getBucket() |
| 165 | 165 | { |
| 166 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
| 166 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
| 175 | 175 | { |
| 176 | 176 | if (!array_key_exists($bucketName, $this->bucketInstances)) { |
| 177 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
| 177 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
| 178 | 178 | } else { |
| 179 | 179 | throw new \LogicException('A bucket instance with this name already exists.'); |
| 180 | 180 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * @param \Psr\Cache\CacheItemInterface $item |
| 56 | - * @return mixed |
|
| 56 | + * @return boolean |
|
| 57 | 57 | * @throws \InvalidArgumentException |
| 58 | 58 | */ |
| 59 | 59 | public function driverWrite(CacheItemInterface $item) |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * @param \Psr\Cache\CacheItemInterface $item |
| 115 | - * @return bool |
|
| 115 | + * @return boolean|null |
|
| 116 | 116 | * @throws \InvalidArgumentException |
| 117 | 117 | */ |
| 118 | 118 | public function driverIsHit(CacheItemInterface $item) |
@@ -140,8 +140,8 @@ |
||
| 140 | 140 | { |
| 141 | 141 | $stat = new driverStatistic(); |
| 142 | 142 | $stat->setInfo('A void info string') |
| 143 | - ->setSize(1337) |
|
| 144 | - ->setData('A void data string'); |
|
| 143 | + ->setSize(1337) |
|
| 144 | + ->setData('A void data string'); |
|
| 145 | 145 | |
| 146 | 146 | return $stat; |
| 147 | 147 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * @param \Psr\Cache\CacheItemInterface $item |
| 56 | - * @return mixed |
|
| 56 | + * @return boolean |
|
| 57 | 57 | * @throws \InvalidArgumentException |
| 58 | 58 | */ |
| 59 | 59 | public function driverWrite(CacheItemInterface $item) |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @param $key |
| 73 | - * @return mixed |
|
| 73 | + * @return boolean |
|
| 74 | 74 | */ |
| 75 | 75 | public function driverRead($key) |
| 76 | 76 | { |
@@ -140,8 +140,8 @@ |
||
| 140 | 140 | { |
| 141 | 141 | $stat = new driverStatistic(); |
| 142 | 142 | $stat->setInfo('A void info string') |
| 143 | - ->setSize(1337) |
|
| 144 | - ->setData('A void data string'); |
|
| 143 | + ->setSize(1337) |
|
| 144 | + ->setData('A void data string'); |
|
| 145 | 145 | |
| 146 | 146 | return $stat; |
| 147 | 147 | } |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | |
| 15 | 15 | namespace phpFastCache\Drivers\Files; |
| 16 | 16 | |
| 17 | -use phpFastCache\Cache\ExtendedCacheItemInterface; |
|
| 18 | 17 | use phpFastCache\Core\DriverAbstract; |
| 19 | 18 | use phpFastCache\Core\PathSeekerTrait; |
| 20 | 19 | use phpFastCache\Core\StandardPsr6StructureTrait; |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | $key = $key[ 0 ]; |
| 254 | 254 | } |
| 255 | 255 | $content[ $key ] = [ |
| 256 | - 'size' => $size, |
|
| 257 | - 'write_time' => (isset($object[ 'write_time' ]) ? $object[ 'write_time' ] : null), |
|
| 256 | + 'size' => $size, |
|
| 257 | + 'write_time' => (isset($object[ 'write_time' ]) ? $object[ 'write_time' ] : null), |
|
| 258 | 258 | ]; |
| 259 | 259 | if ($object->isExpired()) { |
| 260 | 260 | @unlink($file_path); |
@@ -267,11 +267,11 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | $stat->setData($content) |
| 270 | - ->setSize($total - $removed) |
|
| 271 | - ->setInfo('Total [bytes]: ' . $total . ', ' |
|
| 270 | + ->setSize($total - $removed) |
|
| 271 | + ->setInfo('Total [bytes]: ' . $total . ', ' |
|
| 272 | 272 | . 'Expired and removed [bytes]: ' . $removed . ', ' |
| 273 | 273 | . 'Current [bytes], ' . $total - $removed |
| 274 | - ); |
|
| 274 | + ); |
|
| 275 | 275 | |
| 276 | 276 | return $stat; |
| 277 | 277 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @param \Psr\Cache\CacheItemInterface $item |
| 58 | - * @return mixed |
|
| 58 | + * @return boolean|null |
|
| 59 | 59 | * @throws \InvalidArgumentException |
| 60 | 60 | */ |
| 61 | 61 | public function driverWrite(CacheItemInterface $item) |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | /** |
| 212 | 212 | * @param string $optionName |
| 213 | 213 | * @param mixed $optionValue |
| 214 | - * @return bool |
|
| 214 | + * @return boolean|null |
|
| 215 | 215 | * @throws \InvalidArgumentException |
| 216 | 216 | */ |
| 217 | 217 | public static function isValidOption($optionName, $optionValue) |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | /** |
| 242 | - * @return array |
|
| 242 | + * @return string[] |
|
| 243 | 243 | */ |
| 244 | 244 | public static function getValidOptions() |
| 245 | 245 | { |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | - * @return array |
|
| 250 | + * @return string[] |
|
| 251 | 251 | */ |
| 252 | 252 | public static function getRequiredOptions() |
| 253 | 253 | { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | /* |
| 72 | 72 | * Skip if Existing Caching in Options |
| 73 | 73 | */ |
| 74 | - if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true && file_exists($file_path)) { |
|
| 74 | + if (isset($option['skipExisting']) && $option['skipExisting'] == true && file_exists($file_path)) { |
|
| 75 | 75 | $content = $this->readfile($file_path); |
| 76 | 76 | $old = $this->decode($content); |
| 77 | 77 | $toWrite = false; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | public static function isValidOption($optionName, $optionValue) |
| 218 | 218 | { |
| 219 | 219 | parent::isValidOption($optionName, $optionValue); |
| 220 | - switch($optionName) |
|
| 220 | + switch ($optionName) |
|
| 221 | 221 | { |
| 222 | 222 | case 'path': |
| 223 | 223 | return is_string($optionValue); |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | if (strpos($subdirFile, '.') === false) { |
| 295 | 295 | $key = $subdirFile; |
| 296 | 296 | } else { |
| 297 | - $key = explode('.', $subdirFile)[ 0 ]; |
|
| 297 | + $key = explode('.', $subdirFile)[0]; |
|
| 298 | 298 | } |
| 299 | - $content[ $key ] = [ |
|
| 299 | + $content[$key] = [ |
|
| 300 | 300 | 'size' => $size, |
| 301 | - 'write_time' => (isset($object[ 'write_time' ]) ? $object[ 'write_time' ] : null), |
|
| 301 | + 'write_time' => (isset($object['write_time']) ? $object['write_time'] : null), |
|
| 302 | 302 | ]; |
| 303 | 303 | if ($object->isExpired()) { |
| 304 | 304 | @unlink($file_path); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | - * @return bool |
|
| 131 | + * @return boolean|null |
|
| 132 | 132 | */ |
| 133 | 133 | public function driverConnect() |
| 134 | 134 | { |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
| 297 | - * @return mixed|null |
|
| 297 | + * @return boolean |
|
| 298 | 298 | * @throws \InvalidArgumentException |
| 299 | 299 | */ |
| 300 | 300 | public function commit() |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
| 136 | 136 | if (count($servers) < 1) { |
| 137 | 137 | $servers = [ |
| 138 | - ['127.0.0.1', 11211], |
|
| 138 | + ['127.0.0.1', 11211], |
|
| 139 | 139 | ]; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | } else { |
| 188 | 188 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', |
| 189 | - gettype($key))); |
|
| 189 | + gettype($key))); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | return $this->itemInstances[ $key ]; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | return $this; |
| 206 | 206 | } else { |
| 207 | 207 | throw new \InvalidArgumentException(sprintf('Invalid Item Class "%s" for this driver.', |
| 208 | - get_class($item))); |
|
| 208 | + get_class($item))); |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function driverConnect() |
| 134 | 134 | { |
| 135 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
| 135 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
| 136 | 136 | if (count($servers) < 1) { |
| 137 | 137 | $servers = [ |
| 138 | 138 | ['127.0.0.1', 11211], |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | foreach ($servers as $server) { |
| 143 | 143 | try { |
| 144 | - if (!$this->instance->addServer($server[ 0 ], $server[ 1 ])) { |
|
| 144 | + if (!$this->instance->addServer($server[0], $server[1])) { |
|
| 145 | 145 | $this->fallback = true; |
| 146 | 146 | } |
| 147 | 147 | } catch (\Exception $e) { |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | gettype($key))); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return $this->itemInstances[ $key ]; |
|
| 192 | + return $this->itemInstances[$key]; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | public function setItem(CacheItemInterface $item) |
| 201 | 201 | { |
| 202 | 202 | if (__NAMESPACE__ . '\\Item' === get_class($item)) { |
| 203 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
| 203 | + $this->itemInstances[$item->getKey()] = $item; |
|
| 204 | 204 | |
| 205 | 205 | return $this; |
| 206 | 206 | } else { |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | { |
| 219 | 219 | $collection = []; |
| 220 | 220 | foreach ($keys as $key) { |
| 221 | - $collection[ $key ] = $this->getItem($key); |
|
| 221 | + $collection[$key] = $this->getItem($key); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | return $collection; |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | public function saveDeferred(CacheItemInterface $item) |
| 292 | 292 | { |
| 293 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
| 293 | + return $this->deferredList[$item->getKey()] = $item; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | foreach ($this->deferredList as $key => $item) { |
| 304 | 304 | $result = $this->driverWrite($item); |
| 305 | 305 | if ($return !== false) { |
| 306 | - unset($this->deferredList[ $key ]); |
|
| 306 | + unset($this->deferredList[$key]); |
|
| 307 | 307 | $return = $result; |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * @param \Psr\Cache\CacheItemInterface $item |
| 70 | - * @return mixed |
|
| 70 | + * @return boolean |
|
| 71 | 71 | * @throws \InvalidArgumentException |
| 72 | 72 | */ |
| 73 | 73 | public function driverWrite(CacheItemInterface $item) |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | - * @return bool |
|
| 145 | + * @return boolean|null |
|
| 146 | 146 | * @throws MongoConnectionException |
| 147 | 147 | * @throws LogicException |
| 148 | 148 | */ |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | 183 | * @param \Psr\Cache\CacheItemInterface $item |
| 184 | - * @return bool |
|
| 184 | + * @return boolean|null |
|
| 185 | 185 | * @throws \InvalidArgumentException |
| 186 | 186 | */ |
| 187 | 187 | public function driverIsHit(CacheItemInterface $item) |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | if ($item instanceof Item) { |
| 79 | 79 | try { |
| 80 | 80 | $result = (array) $this->getCollection()->update( |
| 81 | - ['_id' => $item->getKey()], |
|
| 82 | - [ |
|
| 81 | + ['_id' => $item->getKey()], |
|
| 82 | + [ |
|
| 83 | 83 | '$set' => [ |
| 84 | - self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : null), |
|
| 85 | - self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
| 84 | + self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : null), |
|
| 85 | + self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
| 86 | 86 | ], |
| 87 | - ], |
|
| 88 | - ['upsert' => true, 'multiple' => false] |
|
| 87 | + ], |
|
| 88 | + ['upsert' => true, 'multiple' => false] |
|
| 89 | 89 | ); |
| 90 | 90 | } catch (MongoCursorException $e) { |
| 91 | 91 | return false; |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | $document = $this->getCollection()->findOne(['_id' => $key], [self::DRIVER_DATA_WRAPPER_INDEX, self::DRIVER_TIME_WRAPPER_INDEX /*'d', 'e'*/]); |
| 107 | 107 | if ($document) { |
| 108 | 108 | return [ |
| 109 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
| 110 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
| 109 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
| 110 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
| 111 | 111 | ]; |
| 112 | 112 | } else { |
| 113 | 113 | return null; |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | * @todo make an url builder |
| 163 | 163 | */ |
| 164 | 164 | $this->instance = $this->instance ?: (new MongodbClient('mongodb://' . |
| 165 | - ($username ?: '') . |
|
| 166 | - ($password ? ":{$password}" : '') . |
|
| 167 | - ($username ? '@' : '') . "{$host}" . |
|
| 168 | - ($port != '27017' ? ":{$port}" : ''), ['timeout' => $timeout * 1000]))->phpFastCache; |
|
| 165 | + ($username ?: '') . |
|
| 166 | + ($password ? ":{$password}" : '') . |
|
| 167 | + ($username ? '@' : '') . "{$host}" . |
|
| 168 | + ($port != '27017' ? ":{$port}" : ''), ['timeout' => $timeout * 1000]))->phpFastCache; |
|
| 169 | 169 | $this->instance->Cache->createIndex([self::DRIVER_TIME_WRAPPER_INDEX => 1], ['expireAfterSeconds' => 0]); |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -206,23 +206,23 @@ discard block |
||
| 206 | 206 | public function getStats() |
| 207 | 207 | { |
| 208 | 208 | $serverStatus = $this->getCollection()->db->command([ |
| 209 | - 'serverStatus' => 1, |
|
| 210 | - 'recordStats' => 0, |
|
| 211 | - 'repl' => 0, |
|
| 212 | - 'metrics' => 0, |
|
| 209 | + 'serverStatus' => 1, |
|
| 210 | + 'recordStats' => 0, |
|
| 211 | + 'repl' => 0, |
|
| 212 | + 'metrics' => 0, |
|
| 213 | 213 | ]); |
| 214 | 214 | $collStats = $this->getCollection()->db->command([ |
| 215 | - 'collStats' => 'Cache', |
|
| 216 | - 'verbose' => true, |
|
| 215 | + 'collStats' => 'Cache', |
|
| 216 | + 'verbose' => true, |
|
| 217 | 217 | ]); |
| 218 | 218 | |
| 219 | 219 | $stats = (new driverStatistic()) |
| 220 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1)) |
|
| 221 | - ->setSize((int) $collStats[ 'size' ]) |
|
| 222 | - ->setRawData([ |
|
| 220 | + ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1)) |
|
| 221 | + ->setSize((int) $collStats[ 'size' ]) |
|
| 222 | + ->setRawData([ |
|
| 223 | 223 | 'serverStatus' => $serverStatus, |
| 224 | 224 | 'collStats' => $collStats, |
| 225 | - ]); |
|
| 225 | + ]); |
|
| 226 | 226 | |
| 227 | 227 | return $stats; |
| 228 | 228 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
| 94 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
| 95 | 95 | } else { |
| 96 | 96 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
| 97 | 97 | } |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | $document = $this->getCollection()->findOne(['_id' => $key], [self::DRIVER_DATA_WRAPPER_INDEX, self::DRIVER_TIME_WRAPPER_INDEX /*'d', 'e'*/]); |
| 107 | 107 | if ($document) { |
| 108 | 108 | return [ |
| 109 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
| 110 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
| 109 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->bin), |
|
| 110 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_TIME_WRAPPER_INDEX]->sec), |
|
| 111 | 111 | ]; |
| 112 | 112 | } else { |
| 113 | 113 | return null; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | if ($item instanceof Item) { |
| 128 | 128 | $deletionResult = (array) $this->getCollection()->remove(['_id' => $item->getKey()], ["w" => 1]); |
| 129 | 129 | |
| 130 | - return (int) $deletionResult[ 'ok' ] === 1 && !$deletionResult[ 'err' ]; |
|
| 130 | + return (int) $deletionResult['ok'] === 1 && !$deletionResult['err']; |
|
| 131 | 131 | } else { |
| 132 | 132 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
| 133 | 133 | } |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | if ($this->instance instanceof MongodbClient) { |
| 152 | 152 | throw new LogicException('Already connected to Mongodb server'); |
| 153 | 153 | } else { |
| 154 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 155 | - $port = isset($server[ 'port' ]) ? $server[ 'port' ] : '27017'; |
|
| 156 | - $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : 3; |
|
| 157 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 158 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 154 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 155 | + $port = isset($server['port']) ? $server['port'] : '27017'; |
|
| 156 | + $timeout = isset($server['timeout']) ? $server['timeout'] : 3; |
|
| 157 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 158 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 159 | 159 | |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | $document = $this->getCollection()->findOne(['_id' => $item->getKey()], [self::DRIVER_TIME_WRAPPER_INDEX /*'d', 'e'*/]); |
| 190 | 190 | if ($document) { |
| 191 | - return $document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec >= time(); |
|
| 191 | + return $document[self::DRIVER_TIME_WRAPPER_INDEX]->sec >= time(); |
|
| 192 | 192 | } else { |
| 193 | 193 | return null; |
| 194 | 194 | } |
@@ -217,8 +217,8 @@ discard block |
||
| 217 | 217 | ]); |
| 218 | 218 | |
| 219 | 219 | $stats = (new driverStatistic()) |
| 220 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1)) |
|
| 221 | - ->setSize((int) $collStats[ 'size' ]) |
|
| 220 | + ->setInfo('MongoDB version ' . $serverStatus['version'] . ', Uptime (in days): ' . round($serverStatus['uptime'] / 86400, 1)) |
|
| 221 | + ->setSize((int) $collStats['size']) |
|
| 222 | 222 | ->setRawData([ |
| 223 | 223 | 'serverStatus' => $serverStatus, |
| 224 | 224 | 'collStats' => $collStats, |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | - * @param $keyword |
|
| 214 | + * @param string $keyword |
|
| 215 | 215 | * @param bool $reset |
| 216 | 216 | * @return PDO |
| 217 | 217 | */ |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | 250 | * @param \Psr\Cache\CacheItemInterface $item |
| 251 | - * @return mixed |
|
| 251 | + * @return boolean |
|
| 252 | 252 | * @throws \InvalidArgumentException |
| 253 | 253 | */ |
| 254 | 254 | public function driverWrite(CacheItemInterface $item) |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | /** |
| 402 | - * @return bool |
|
| 402 | + * @return boolean|null |
|
| 403 | 403 | */ |
| 404 | 404 | public function driverConnect() |
| 405 | 405 | { |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`"); |
| 167 | 167 | $stm->execute(); |
| 168 | 168 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 169 | - if (!isset($row[ 'db' ])) { |
|
| 169 | + if (!isset($row['db'])) { |
|
| 170 | 170 | $db = 1; |
| 171 | - } elseif ($row[ 'db' ] <= 1) { |
|
| 171 | + } elseif ($row['db'] <= 1) { |
|
| 172 | 172 | $db = 1; |
| 173 | 173 | } else { |
| 174 | - $db = $row[ 'db' ]; |
|
| 174 | + $db = $row['db']; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // check file size |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | ':keyword' => $keyword, |
| 194 | 194 | ]); |
| 195 | 195 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 196 | - if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
|
| 197 | - $db = $row[ 'db' ]; |
|
| 196 | + if (isset($row['db']) && $row['db'] != '') { |
|
| 197 | + $db = $row['db']; |
|
| 198 | 198 | } else { |
| 199 | 199 | /* |
| 200 | 200 | * Insert new to Indexing |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | /** |
| 226 | 226 | * init instant |
| 227 | 227 | */ |
| 228 | - if (!isset($this->instance[ $instant ])) { |
|
| 228 | + if (!isset($this->instance[$instant])) { |
|
| 229 | 229 | // check DB Files ready or not |
| 230 | 230 | $createTable = false; |
| 231 | 231 | if (!file_exists($this->SqliteDir . '/db' . $instant) || $reset == true) { |
@@ -238,12 +238,12 @@ discard block |
||
| 238 | 238 | $this->initDB($PDO); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $this->instance[ $instant ] = $PDO; |
|
| 241 | + $this->instance[$instant] = $PDO; |
|
| 242 | 242 | unset($PDO); |
| 243 | 243 | |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - return $this->instance[ $instant ]; |
|
| 246 | + return $this->instance[$instant]; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * Check for Cross-Driver type confusion |
| 258 | 258 | */ |
| 259 | 259 | if ($item instanceof Item) { |
| 260 | - $skipExisting = isset($this->config[ 'skipExisting' ]) ? $this->config[ 'skipExisting' ] : false; |
|
| 260 | + $skipExisting = isset($this->config['skipExisting']) ? $this->config['skipExisting'] : false; |
|
| 261 | 261 | $toWrite = true; |
| 262 | 262 | |
| 263 | 263 | // check in cache first |
@@ -333,18 +333,18 @@ discard block |
||
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if (isset($row[ 'id' ])) { |
|
| 336 | + if (isset($row['id'])) { |
|
| 337 | 337 | /** |
| 338 | 338 | * @var $item ExtendedCacheItemInterface |
| 339 | 339 | */ |
| 340 | - $item = $this->decode($row[ 'object' ]); |
|
| 340 | + $item = $this->decode($row['object']); |
|
| 341 | 341 | if ($item instanceof ExtendedCacheItemInterface && $item->isExpired()) { |
| 342 | 342 | $this->driverDelete($item); |
| 343 | 343 | |
| 344 | 344 | return null; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - return $this->decode($row[ 'object' ]); |
|
| 347 | + return $this->decode($row['object']); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | return null; |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | ':U' => time(), |
| 435 | 435 | ]); |
| 436 | 436 | $data = $stm->fetch(PDO::FETCH_ASSOC); |
| 437 | - if ($data[ 'total' ] >= 1) { |
|
| 437 | + if ($data['total'] >= 1) { |
|
| 438 | 438 | return true; |
| 439 | 439 | } else { |
| 440 | 440 | return false; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE); |
| 152 | 152 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
| 153 | - PDO::ERRMODE_EXCEPTION); |
|
| 153 | + PDO::ERRMODE_EXCEPTION); |
|
| 154 | 154 | |
| 155 | 155 | if ($createTable == true) { |
| 156 | 156 | $this->initIndexing($PDO); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | // look for keyword |
| 186 | 186 | $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); |
| 187 | 187 | $stm->execute([ |
| 188 | - ':keyword' => $keyword, |
|
| 188 | + ':keyword' => $keyword, |
|
| 189 | 189 | ]); |
| 190 | 190 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 191 | 191 | if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | $db = $this->currentDB; |
| 198 | 198 | $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); |
| 199 | 199 | $stm->execute([ |
| 200 | - ':keyword' => $keyword, |
|
| 201 | - ':db' => $db, |
|
| 200 | + ':keyword' => $keyword, |
|
| 201 | + ':db' => $db, |
|
| 202 | 202 | ]); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | if ($toWrite == true) { |
| 270 | 270 | try { |
| 271 | 271 | $stm = $this->getDb($item->getKey()) |
| 272 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 272 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 273 | 273 | $stm->execute([ |
| 274 | - ':keyword' => $item->getKey(), |
|
| 275 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 276 | - ':exp' => time() + $item->getTtl(), |
|
| 274 | + ':keyword' => $item->getKey(), |
|
| 275 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 276 | + ':exp' => time() + $item->getTtl(), |
|
| 277 | 277 | ]); |
| 278 | 278 | |
| 279 | 279 | return true; |
@@ -281,11 +281,11 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | try { |
| 283 | 283 | $stm = $this->getDb($item->getKey(), true) |
| 284 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 284 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 285 | 285 | $stm->execute([ |
| 286 | - ':keyword' => $item->getKey(), |
|
| 287 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 288 | - ':exp' => time() + $item->getTtl(), |
|
| 286 | + ':keyword' => $item->getKey(), |
|
| 287 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 288 | + ':exp' => time() + $item->getTtl(), |
|
| 289 | 289 | ]); |
| 290 | 290 | } catch (PDOException $e) { |
| 291 | 291 | return false; |
@@ -307,20 +307,20 @@ discard block |
||
| 307 | 307 | { |
| 308 | 308 | try { |
| 309 | 309 | $stm = $this->getDb($key) |
| 310 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
| 310 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
| 311 | 311 | $stm->execute([ |
| 312 | - ':keyword' => $key, |
|
| 313 | - ':U' => time(), |
|
| 312 | + ':keyword' => $key, |
|
| 313 | + ':U' => time(), |
|
| 314 | 314 | ]); |
| 315 | 315 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 316 | 316 | |
| 317 | 317 | } catch (PDOException $e) { |
| 318 | 318 | try { |
| 319 | 319 | $stm = $this->getDb($key, true) |
| 320 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
| 320 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
| 321 | 321 | $stm->execute([ |
| 322 | - ':keyword' => $key, |
|
| 323 | - ':U' => time(), |
|
| 322 | + ':keyword' => $key, |
|
| 323 | + ':U' => time(), |
|
| 324 | 324 | ]); |
| 325 | 325 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 326 | 326 | } catch (PDOException $e) { |
@@ -358,13 +358,13 @@ discard block |
||
| 358 | 358 | if ($item instanceof Item) { |
| 359 | 359 | try { |
| 360 | 360 | $stm = $this->getDb($item->getKey()) |
| 361 | - //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
| 362 | - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
| 361 | + //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
| 362 | + ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
| 363 | 363 | |
| 364 | 364 | return $stm->execute([ |
| 365 | 365 | // ':id' => $row[ 'id' ], |
| 366 | - ':keyword' => $item->getKey(), |
|
| 367 | - ':U' => time(), |
|
| 366 | + ':keyword' => $item->getKey(), |
|
| 367 | + ':U' => time(), |
|
| 368 | 368 | ]); |
| 369 | 369 | } catch (PDOException $e) { |
| 370 | 370 | return false; |
@@ -422,10 +422,10 @@ discard block |
||
| 422 | 422 | * @todo: Check expiration time here |
| 423 | 423 | */ |
| 424 | 424 | $stm = $this->getDb($item->getKey()) |
| 425 | - ->prepare("SELECT COUNT(`id`) as `total` FROM `caching` WHERE (`keyword`=:keyword) AND (`exp` <= :U) "); |
|
| 425 | + ->prepare("SELECT COUNT(`id`) as `total` FROM `caching` WHERE (`keyword`=:keyword) AND (`exp` <= :U) "); |
|
| 426 | 426 | $stm->execute([ |
| 427 | - ':keyword' => $item->getKey(), |
|
| 428 | - ':U' => time(), |
|
| 427 | + ':keyword' => $item->getKey(), |
|
| 428 | + ':U' => time(), |
|
| 429 | 429 | ]); |
| 430 | 430 | $data = $stm->fetch(PDO::FETCH_ASSOC); |
| 431 | 431 | if ($data[ 'total' ] >= 1) { |
@@ -464,11 +464,11 @@ discard block |
||
| 464 | 464 | try { |
| 465 | 465 | $PDO = new PDO("sqlite:" . $file_path); |
| 466 | 466 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
| 467 | - PDO::ERRMODE_EXCEPTION); |
|
| 467 | + PDO::ERRMODE_EXCEPTION); |
|
| 468 | 468 | |
| 469 | 469 | $stm = $PDO->prepare("DELETE FROM `caching` WHERE `exp` <= :U"); |
| 470 | 470 | $stm->execute([ |
| 471 | - ':U' => date('U'), |
|
| 471 | + ':U' => date('U'), |
|
| 472 | 472 | ]); |
| 473 | 473 | |
| 474 | 474 | $PDO->exec('VACUUM;'); |
@@ -482,9 +482,9 @@ discard block |
||
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | $stat->setSize($optimized) |
| 485 | - ->setInfo('Total before removing expired entries [bytes]: ' . $total . ', ' |
|
| 485 | + ->setInfo('Total before removing expired entries [bytes]: ' . $total . ', ' |
|
| 486 | 486 | . 'Optimized after removing expired entries [bytes]: ' . $optimized |
| 487 | - ); |
|
| 487 | + ); |
|
| 488 | 488 | |
| 489 | 489 | return $stat; |
| 490 | 490 | } |