Completed
Pull Request — final (#503)
by Georges
04:02 queued 01:50
created
src/phpFastCache/Drivers/Redis/Driver.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
              * @see https://redis.io/commands/setex
75 75
              * @see https://redis.io/commands/expire
76 76
              */
77
-            if($ttl <= 0){
77
+            if ($ttl <= 0) {
78 78
                 return $this->instance->expire($item->getKey(), 0);
79
-            }else{
79
+            } else {
80 80
                 return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)));
81 81
             }
82 82
         } else {
@@ -134,20 +134,20 @@  discard block
 block discarded – undo
134 134
         } else {
135 135
             $this->instance = $this->instance ?: new RedisClient();
136 136
 
137
-            $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1';
138
-            $port = isset($this->config[ 'port' ]) ? (int)$this->config[ 'port' ] : '6379';
139
-            $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : '';
140
-            $database = isset($this->config[ 'database' ]) ? $this->config[ 'database' ] : '';
141
-            $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : '';
137
+            $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1';
138
+            $port = isset($this->config['port']) ? (int) $this->config['port'] : '6379';
139
+            $password = isset($this->config['password']) ? $this->config['password'] : '';
140
+            $database = isset($this->config['database']) ? $this->config['database'] : '';
141
+            $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : '';
142 142
 
143
-            if (!$this->instance->connect($host, (int)$port, (int)$timeout)) {
143
+            if (!$this->instance->connect($host, (int) $port, (int) $timeout)) {
144 144
                 return false;
145 145
             } else {
146 146
                 if ($password && !$this->instance->auth($password)) {
147 147
                     return false;
148 148
                 }
149 149
                 if ($database) {
150
-                    $this->instance->select((int)$database);
150
+                    $this->instance->select((int) $database);
151 151
                 }
152 152
 
153 153
                 return true;
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
     {
169 169
         // used_memory
170 170
         $info = $this->instance->info();
171
-        $date = (new \DateTime())->setTimestamp(time() - $info[ 'uptime_in_seconds' ]);
171
+        $date = (new \DateTime())->setTimestamp(time() - $info['uptime_in_seconds']);
172 172
 
173 173
         return (new DriverStatistic())
174 174
           ->setData(implode(', ', array_keys($this->itemInstances)))
175 175
           ->setRawData($info)
176
-          ->setSize($info[ 'used_memory' ])
176
+          ->setSize($info['used_memory'])
177 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
-            $info[ 'redis_version' ], $date->format(DATE_RFC2822)));
178
+            $info['redis_version'], $date->format(DATE_RFC2822)));
179 179
     }
180 180
 }
181 181
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
              */
77 77
             if($ttl <= 0){
78 78
                 return $this->instance->expire($item->getKey(), 0);
79
-            }else{
79
+            } else{
80 80
                 return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)));
81 81
             }
82 82
         } else {
Please login to merge, or discard this patch.
src/phpFastCache/Drivers/Predis/Driver.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
              * @see https://redis.io/commands/setex
79 79
              * @see https://redis.io/commands/expire
80 80
              */
81
-            if($ttl <= 0){
81
+            if ($ttl <= 0) {
82 82
                 return $this->instance->expire($item->getKey(), 0);
83
-            }else{
83
+            } else {
84 84
                 return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)));
85 85
             }
86 86
         } else {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      */
134 134
     protected function driverConnect()
135 135
     {
136
-        $config = isset($this->config[ 'predis' ]) ? $this->config[ 'predis' ] : [];
136
+        $config = isset($this->config['predis']) ? $this->config['predis'] : [];
137 137
 
138 138
         $this->instance = new PredisClient(array_merge([
139 139
           'host' => '127.0.0.1',
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
     public function getStats()
178 178
     {
179 179
         $info = $this->instance->info();
180
-        $size = (isset($info[ 'Memory' ][ 'used_memory' ]) ? $info[ 'Memory' ][ 'used_memory' ] : 0);
181
-        $version = (isset($info[ 'Server' ][ 'redis_version' ]) ? $info[ 'Server' ][ 'redis_version' ] : 0);
182
-        $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date');
180
+        $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0);
181
+        $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0);
182
+        $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date');
183 183
 
184 184
         return (new DriverStatistic())
185 185
           ->setData(implode(', ', array_keys($this->itemInstances)))
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
              */
77 77
             if($ttl <= 0){
78 78
                 return $this->instance->expire($item->getKey(), 0);
79
-            }else{
79
+            } else{
80 80
                 return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)));
81 81
             }
82 82
         } else {
Please login to merge, or discard this patch.