@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | use CouchbaseCluster as CouchbaseClient; |
| 19 | 19 | use Phpfastcache\Core\Pool\{ |
| 20 | - DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
| 20 | + DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
| 21 | 21 | }; |
| 22 | 22 | use Phpfastcache\Entities\DriverStatistic; |
| 23 | 23 | use Phpfastcache\Exceptions\{ |
| 24 | - PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 24 | + PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 25 | 25 | }; |
| 26 | 26 | use Phpfastcache\Util\ArrayObject; |
| 27 | 27 | use Psr\Cache\CacheItemInterface; |
@@ -187,10 +187,10 @@ discard block |
||
| 187 | 187 | $info = $this->getBucket()->manager()->info(); |
| 188 | 188 | |
| 189 | 189 | return (new DriverStatistic()) |
| 190 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 191 | - ->setRawData($info) |
|
| 192 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 193 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
| 194 | - 1) . "\n For more information see RawData."); |
|
| 190 | + ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 191 | + ->setRawData($info) |
|
| 192 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 193 | + ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
| 194 | + 1) . "\n For more information see RawData."); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -declare(strict_types=1); |
|
| 14 | +declare(strict_types = 1); |
|
| 15 | 15 | |
| 16 | 16 | namespace Phpfastcache\Drivers\Couchbase; |
| 17 | 17 | |
@@ -69,16 +69,16 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $this->instance = new CouchbaseClient("couchbase://{$clientConfig['host']}:{$clientConfig['port']}"); |
| 71 | 71 | |
| 72 | - if ($clientConfig[ 'username' ]) { |
|
| 72 | + if ($clientConfig['username']) { |
|
| 73 | 73 | $authenticator = new \Couchbase\ClassicAuthenticator(); |
| 74 | - $authenticator->cluster($clientConfig[ 'username' ], $clientConfig[ 'password' ]); |
|
| 74 | + $authenticator->cluster($clientConfig['username'], $clientConfig['password']); |
|
| 75 | 75 | //$authenticator->bucket('protected', 'secret'); |
| 76 | 76 | $this->instance->authenticate($authenticator); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - foreach ($clientConfig[ 'buckets' ] as $bucket) { |
|
| 80 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
| 81 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
| 79 | + foreach ($clientConfig['buckets'] as $bucket) { |
|
| 80 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
| 81 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | return true; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | if ($item instanceof Item) { |
| 114 | 114 | try { |
| 115 | - return (bool)$this->getBucket()->upsert($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), ['expiry' => $item->getTtl()]); |
|
| 115 | + return (bool) $this->getBucket()->upsert($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), ['expiry' => $item->getTtl()]); |
|
| 116 | 116 | } catch (\CouchbaseException $e) { |
| 117 | 117 | return false; |
| 118 | 118 | } |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | * Check for Cross-Driver type confusion |
| 133 | 133 | */ |
| 134 | 134 | if ($item instanceof Item) { |
| 135 | - try{ |
|
| 136 | - return (bool)$this->getBucket()->remove($item->getEncodedKey()); |
|
| 137 | - }catch (\Couchbase\Exception $e){ |
|
| 135 | + try { |
|
| 136 | + return (bool) $this->getBucket()->remove($item->getEncodedKey()); |
|
| 137 | + } catch (\Couchbase\Exception $e) { |
|
| 138 | 138 | return $e->getCode() === COUCHBASE_KEY_ENOENT; |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | protected function getBucket(): \CouchbaseBucket |
| 158 | 158 | { |
| 159 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
| 159 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
| 168 | 168 | { |
| 169 | 169 | if (!\array_key_exists($bucketName, $this->bucketInstances)) { |
| 170 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
| 170 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
| 171 | 171 | } else { |
| 172 | 172 | throw new PhpfastcacheLogicException('A bucket instance with this name already exists.'); |
| 173 | 173 | } |
@@ -187,10 +187,10 @@ discard block |
||
| 187 | 187 | $info = $this->getBucket()->manager()->info(); |
| 188 | 188 | |
| 189 | 189 | return (new DriverStatistic()) |
| 190 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 190 | + ->setSize($info['basicStats']['diskUsed']) |
|
| 191 | 191 | ->setRawData($info) |
| 192 | 192 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 193 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
| 193 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, |
|
| 194 | 194 | 1) . "\n For more information see RawData."); |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | \ No newline at end of file |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 20 | 20 | use Phpfastcache\Drivers\Couchbase\Driver as CouchbaseDriver; |
| 21 | 21 | use Phpfastcache\Exceptions\{ |
| 22 | - PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 22 | + PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 23 | 23 | }; |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | use PDOException; |
| 20 | 20 | use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface, IO\IOHelperTrait}; |
| 21 | 21 | use Phpfastcache\Exceptions\{ |
| 22 | - PhpfastcacheInvalidArgumentException, PhpfastcacheIOException |
|
| 22 | + PhpfastcacheInvalidArgumentException, PhpfastcacheIOException |
|
| 23 | 23 | }; |
| 24 | 24 | use Psr\Cache\CacheItemInterface; |
| 25 | 25 | |
@@ -108,18 +108,18 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | try { |
| 110 | 110 | $stm = $this->getDb($item->getKey()) |
| 111 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
| 111 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
| 112 | 112 | $stm->execute([ |
| 113 | - ':keyword' => $item->getKey(), |
|
| 113 | + ':keyword' => $item->getKey(), |
|
| 114 | 114 | ]); |
| 115 | 115 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 116 | 116 | |
| 117 | 117 | } catch (PDOException $e) { |
| 118 | 118 | try { |
| 119 | 119 | $stm = $this->getDb($item->getKey(), true) |
| 120 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
| 120 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
| 121 | 121 | $stm->execute([ |
| 122 | - ':keyword' => $item->getKey(), |
|
| 122 | + ':keyword' => $item->getKey(), |
|
| 123 | 123 | ]); |
| 124 | 124 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 125 | 125 | } catch (PDOException $e) { |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | if ($toWrite == true) { |
| 163 | 163 | try { |
| 164 | 164 | $stm = $this->getDb($item->getKey()) |
| 165 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 165 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 166 | 166 | $stm->execute([ |
| 167 | - ':keyword' => $item->getKey(), |
|
| 168 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 169 | - ':exp' => $item->getExpirationDate()->getTimestamp(), |
|
| 167 | + ':keyword' => $item->getKey(), |
|
| 168 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 169 | + ':exp' => $item->getExpirationDate()->getTimestamp(), |
|
| 170 | 170 | ]); |
| 171 | 171 | |
| 172 | 172 | return true; |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | try { |
| 176 | 176 | $stm = $this->getDb($item->getKey(), true) |
| 177 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 177 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 178 | 178 | $stm->execute([ |
| 179 | - ':keyword' => $item->getKey(), |
|
| 180 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 181 | - ':exp' => $item->getExpirationDate()->getTimestamp(), |
|
| 179 | + ':keyword' => $item->getKey(), |
|
| 180 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 181 | + ':exp' => $item->getExpirationDate()->getTimestamp(), |
|
| 182 | 182 | ]); |
| 183 | 183 | } catch (PDOException $e) { |
| 184 | 184 | return false; |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | if ($item instanceof Item) { |
| 206 | 206 | try { |
| 207 | 207 | $stm = $this->getDb($item->getKey()) |
| 208 | - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
| 208 | + ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
| 209 | 209 | |
| 210 | 210 | return $stm->execute([ |
| 211 | - ':keyword' => $item->getKey(), |
|
| 212 | - ':U' => time(), |
|
| 211 | + ':keyword' => $item->getKey(), |
|
| 212 | + ':U' => time(), |
|
| 213 | 213 | ]); |
| 214 | 214 | } catch (PDOException $e) { |
| 215 | 215 | return false; |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE); |
| 291 | 291 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
| 292 | - PDO::ERRMODE_EXCEPTION); |
|
| 292 | + PDO::ERRMODE_EXCEPTION); |
|
| 293 | 293 | |
| 294 | 294 | if ($createTable == true) { |
| 295 | 295 | $this->initIndexing($PDO); |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | // look for keyword |
| 325 | 325 | $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); |
| 326 | 326 | $stm->execute([ |
| 327 | - ':keyword' => $keyword, |
|
| 327 | + ':keyword' => $keyword, |
|
| 328 | 328 | ]); |
| 329 | 329 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 330 | 330 | if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | $db = $this->currentDB; |
| 337 | 337 | $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); |
| 338 | 338 | $stm->execute([ |
| 339 | - ':keyword' => $keyword, |
|
| 340 | - ':db' => $db, |
|
| 339 | + ':keyword' => $keyword, |
|
| 340 | + ':db' => $db, |
|
| 341 | 341 | ]); |
| 342 | 342 | } |
| 343 | 343 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 20 | 20 | use Phpfastcache\Drivers\Sqlite\Driver as SqliteDriver; |
| 21 | 21 | use Phpfastcache\Exceptions\{ |
| 22 | - PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 22 | + PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 23 | 23 | }; |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface}; |
| 19 | 19 | use Phpfastcache\Entities\DriverStatistic; |
| 20 | 20 | use Phpfastcache\Exceptions\{ |
| 21 | - PhpfastcacheInvalidArgumentException |
|
| 21 | + PhpfastcacheInvalidArgumentException |
|
| 22 | 22 | }; |
| 23 | 23 | use Psr\Cache\CacheItemInterface; |
| 24 | 24 | |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | { |
| 130 | 130 | $stat = new DriverStatistic(); |
| 131 | 131 | $stat->setInfo('[Memstatic] A memory static driver') |
| 132 | - ->setSize(mb_strlen(\serialize($this->staticStack))) |
|
| 133 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 134 | - ->setRawData($this->staticStack); |
|
| 132 | + ->setSize(mb_strlen(\serialize($this->staticStack))) |
|
| 133 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 134 | + ->setRawData($this->staticStack); |
|
| 135 | 135 | |
| 136 | 136 | return $stat; |
| 137 | 137 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 20 | 20 | use Phpfastcache\Drivers\Memstatic\Driver as MemstaticDriver; |
| 21 | 21 | use Phpfastcache\Exceptions\{ |
| 22 | - PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 22 | + PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 23 | 23 | }; |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface}; |
| 19 | 19 | use Phpfastcache\Entities\DriverStatistic; |
| 20 | 20 | use Phpfastcache\Exceptions\{ |
| 21 | - PhpfastcacheInvalidArgumentException |
|
| 21 | + PhpfastcacheInvalidArgumentException |
|
| 22 | 22 | }; |
| 23 | 23 | use Psr\Cache\CacheItemInterface; |
| 24 | 24 | |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | $info = xcache_info(XC_TYPE_VAR, 0); |
| 126 | 126 | |
| 127 | 127 | return (new DriverStatistic()) |
| 128 | - ->setSize(abs($info[ 'size' ] - $info[ 'avail' ])) |
|
| 129 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 130 | - ->setInfo(\sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, \str_replace(' ', ', ', XCACHE_MODULES))) |
|
| 131 | - ->setRawData($info); |
|
| 128 | + ->setSize(abs($info[ 'size' ] - $info[ 'avail' ])) |
|
| 129 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 130 | + ->setInfo(\sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, \str_replace(' ', ', ', XCACHE_MODULES))) |
|
| 131 | + ->setRawData($info); |
|
| 132 | 132 | } |
| 133 | 133 | throw new \RuntimeException("PhpFastCache is not able to read Xcache configuration. Please put this to your php.ini:\n |
| 134 | 134 | [xcache.admin] |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 20 | 20 | use Phpfastcache\Drivers\Xcache\Driver as XcacheDriver; |
| 21 | 21 | use Phpfastcache\Exceptions\{ |
| 22 | - PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 22 | + PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException |
|
| 23 | 23 | }; |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface}; |
| 20 | 20 | use Phpfastcache\Entities\DriverStatistic; |
| 21 | 21 | use Phpfastcache\Exceptions\{ |
| 22 | - PhpfastcacheInvalidArgumentException, PhpfastcacheDriverException |
|
| 22 | + PhpfastcacheInvalidArgumentException, PhpfastcacheDriverException |
|
| 23 | 23 | }; |
| 24 | 24 | use Phpfastcache\Util\ArrayObject; |
| 25 | 25 | use Predis\Client as PredisClient; |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | if(!empty($this->config->getOption('path'))){ |
| 59 | 59 | $this->instance = new PredisClient([ |
| 60 | - 'scheme' => 'unix', |
|
| 61 | - 'path' => $this->config->getOption('path') |
|
| 60 | + 'scheme' => 'unix', |
|
| 61 | + 'path' => $this->config->getOption('path') |
|
| 62 | 62 | ]); |
| 63 | 63 | }else{ |
| 64 | 64 | $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray()); |
@@ -171,10 +171,10 @@ discard block |
||
| 171 | 171 | $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
| 172 | 172 | |
| 173 | 173 | return (new DriverStatistic()) |
| 174 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 175 | - ->setRawData($info) |
|
| 176 | - ->setSize((int) $size) |
|
| 177 | - ->setInfo(\sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
| 174 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 175 | + ->setRawData($info) |
|
| 176 | + ->setSize((int) $size) |
|
| 177 | + ->setInfo(\sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
| 178 | 178 | $version, $date->format(DATE_RFC2822))); |
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | \ No newline at end of file |