@@ -115,10 +115,10 @@ |
||
| 115 | 115 | public function getPredisConfigArray(): array |
| 116 | 116 | { |
| 117 | 117 | return [ |
| 118 | - 'host' => $this->getHost(), |
|
| 119 | - 'port' => $this->getPort(), |
|
| 120 | - 'password' => $this->getPassword() ?: null, |
|
| 121 | - 'database' => $this->getDatabase(), |
|
| 118 | + 'host' => $this->getHost(), |
|
| 119 | + 'port' => $this->getPort(), |
|
| 120 | + 'password' => $this->getPassword() ?: null, |
|
| 121 | + 'database' => $this->getDatabase(), |
|
| 122 | 122 | ]; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -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, PhpfastcacheLogicException |
|
| 22 | + PhpfastcacheInvalidArgumentException, PhpfastcacheDriverException, PhpfastcacheLogicException |
|
| 23 | 23 | }; |
| 24 | 24 | use Phpfastcache\Util\ArrayObject; |
| 25 | 25 | use Predis\Client as PredisClient; |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | if(!empty($this->getConfig()->getPath())){ |
| 76 | 76 | $this->instance = new PredisClient([ |
| 77 | - 'scheme' => 'unix', |
|
| 78 | - 'path' => $this->getConfig()->getPath() |
|
| 77 | + 'scheme' => 'unix', |
|
| 78 | + 'path' => $this->getConfig()->getPath() |
|
| 79 | 79 | ]); |
| 80 | 80 | }else{ |
| 81 | 81 | $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray()); |
@@ -188,10 +188,10 @@ discard block |
||
| 188 | 188 | $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(\time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
| 189 | 189 | |
| 190 | 190 | return (new DriverStatistic()) |
| 191 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 192 | - ->setRawData($info) |
|
| 193 | - ->setSize((int) $size) |
|
| 194 | - ->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.", |
|
| 191 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 192 | + ->setRawData($info) |
|
| 193 | + ->setSize((int) $size) |
|
| 194 | + ->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.", |
|
| 195 | 195 | $version, $date->format(DATE_RFC2822))); |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | \ No newline at end of file |
@@ -64,20 +64,20 @@ discard block |
||
| 64 | 64 | * In case of an user-provided |
| 65 | 65 | * Predis client just return here |
| 66 | 66 | */ |
| 67 | - if($this->getConfig()->getPredisClient() instanceof PredisClient){ |
|
| 67 | + if ($this->getConfig()->getPredisClient() instanceof PredisClient) { |
|
| 68 | 68 | $this->instance = $this->getConfig()->getPredisClient(); |
| 69 | - if(!$this->instance->isConnected()){ |
|
| 69 | + if (!$this->instance->isConnected()) { |
|
| 70 | 70 | $this->instance->connect(); |
| 71 | 71 | } |
| 72 | 72 | return true; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if(!empty($this->getConfig()->getPath())){ |
|
| 75 | + if (!empty($this->getConfig()->getPath())) { |
|
| 76 | 76 | $this->instance = new PredisClient([ |
| 77 | 77 | 'scheme' => 'unix', |
| 78 | 78 | 'path' => $this->getConfig()->getPath() |
| 79 | 79 | ]); |
| 80 | - }else{ |
|
| 80 | + } else { |
|
| 81 | 81 | $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray()); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @see https://redis.io/commands/expire |
| 124 | 124 | */ |
| 125 | 125 | if ($ttl <= 0) { |
| 126 | - return (bool)$this->instance->expire($item->getKey(), 0); |
|
| 126 | + return (bool) $this->instance->expire($item->getKey(), 0); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload() === 'OK'; |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | public function getStats(): DriverStatistic |
| 184 | 184 | { |
| 185 | 185 | $info = $this->instance->info(); |
| 186 | - $size = (isset($info[ 'Memory' ][ 'used_memory' ]) ? $info[ 'Memory' ][ 'used_memory' ] : 0); |
|
| 187 | - $version = (isset($info[ 'Server' ][ 'redis_version' ]) ? $info[ 'Server' ][ 'redis_version' ] : 0); |
|
| 188 | - $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(\time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
| 186 | + $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
|
| 187 | + $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
|
| 188 | + $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(\time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
| 189 | 189 | |
| 190 | 190 | return (new DriverStatistic()) |
| 191 | 191 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * In case of an user-provided |
| 60 | 60 | * Redis client just return here |
| 61 | 61 | */ |
| 62 | - if($this->getConfig()->getRedisClient() instanceof RedisClient){ |
|
| 62 | + if ($this->getConfig()->getRedisClient() instanceof RedisClient) { |
|
| 63 | 63 | /** |
| 64 | 64 | * Unlike Predis, we can't test if we're are connected |
| 65 | 65 | * or not, so let's just assume that we are |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * Check for Cross-Driver type confusion |
| 148 | 148 | */ |
| 149 | 149 | if ($item instanceof Item) { |
| 150 | - return (bool)$this->instance->del($item->getKey()); |
|
| 150 | + return (bool) $this->instance->del($item->getKey()); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | { |
| 175 | 175 | // used_memory |
| 176 | 176 | $info = $this->instance->info(); |
| 177 | - $date = (new \DateTime())->setTimestamp(\time() - $info[ 'uptime_in_seconds' ]); |
|
| 177 | + $date = (new \DateTime())->setTimestamp(\time() - $info['uptime_in_seconds']); |
|
| 178 | 178 | |
| 179 | 179 | return (new DriverStatistic()) |
| 180 | 180 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 181 | 181 | ->setRawData($info) |
| 182 | - ->setSize((int)$info[ 'used_memory' ]) |
|
| 182 | + ->setSize((int) $info['used_memory']) |
|
| 183 | 183 | ->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.", |
| 184 | - $info[ 'redis_version' ], $date->format(DATE_RFC2822))); |
|
| 184 | + $info['redis_version'], $date->format(DATE_RFC2822))); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | \ No newline at end of file |