@@ -5,4 +5,5 @@ |
||
| 5 | 5 | use Clue\Redis\Protocol\Model\ModelInterface as ClueModelInterface; |
| 6 | 6 | |
| 7 | 7 | interface RequestInterface extends ClueModelInterface |
| 8 | -{} |
|
| 8 | +{ |
|
| 9 | +} |
|
@@ -128,9 +128,11 @@ discard block |
||
| 128 | 128 | $stream = $this->createClient($this->endpoint); |
| 129 | 129 | } |
| 130 | 130 | catch (Error $ex) |
| 131 | - {} |
|
| 131 | + { |
|
| 132 | +} |
|
| 132 | 133 | catch (Exception $ex) |
| 133 | - {} |
|
| 134 | + { |
|
| 135 | +} |
|
| 134 | 136 | |
| 135 | 137 | if ($ex !== null) |
| 136 | 138 | { |
@@ -320,9 +322,11 @@ discard block |
||
| 320 | 322 | return new Socket($endpoint, $this->loop); |
| 321 | 323 | } |
| 322 | 324 | catch (Error $ex) |
| 323 | - {} |
|
| 325 | + { |
|
| 326 | +} |
|
| 324 | 327 | catch (Exception $ex) |
| 325 | - {} |
|
| 328 | + { |
|
| 329 | +} |
|
| 326 | 330 | |
| 327 | 331 | throw new ExecutionException('Redis connection socket could not be created!', 0, $ex); |
| 328 | 332 | } |
@@ -49,10 +49,12 @@ discard block |
||
| 49 | 49 | $args = [$key]; |
| 50 | 50 | |
| 51 | 51 | return $this->dispatch(Builder::build($command, $args))->then(function ($value) { |
| 52 | - if (!empty($value)) { |
|
| 52 | + if (!empty($value)) |
|
| 53 | + { |
|
| 53 | 54 | $tmp = []; |
| 54 | 55 | $size = count($value); |
| 55 | - for ($i=0; $i<$size; $i+=2) { |
|
| 56 | + for ($i=0; $i<$size; $i+=2) |
|
| 57 | + { |
|
| 56 | 58 | $field = $value[$i]; |
| 57 | 59 | $val = $value[$i+1]; |
| 58 | 60 | $tmp[$field] = $val; |
@@ -133,8 +135,10 @@ discard block |
||
| 133 | 135 | { |
| 134 | 136 | $command = Enum::HMSET; |
| 135 | 137 | $args = [$key]; |
| 136 | - if (!empty($fvMap)) { |
|
| 137 | - foreach ($fvMap as $field => $value) { |
|
| 138 | + if (!empty($fvMap)) |
|
| 139 | + { |
|
| 140 | + foreach ($fvMap as $field => $value) |
|
| 141 | + { |
|
| 138 | 142 | $tmp[] = $field; |
| 139 | 143 | $tmp[] = $value; |
| 140 | 144 | } |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | $args = $keys; |
| 27 | 27 | $promise = $this->dispatch(Builder::build($command, $args)); |
| 28 | 28 | $promise = $promise->then(function ($value) { |
| 29 | - if (is_array($value)) { |
|
| 29 | + if (is_array($value)) |
|
| 30 | + { |
|
| 30 | 31 | list($k,$v) = $value; |
| 31 | 32 | |
| 32 | 33 | return [ |
@@ -53,7 +54,8 @@ discard block |
||
| 53 | 54 | $args = $keys; |
| 54 | 55 | $promise = $this->dispatch(Builder::build($command, $args)); |
| 55 | 56 | $promise = $promise->then(function ($value) { |
| 56 | - if (is_array($value)) { |
|
| 57 | + if (is_array($value)) |
|
| 58 | + { |
|
| 57 | 59 | list($k,$v) = $value; |
| 58 | 60 | |
| 59 | 61 | return [ |
@@ -104,7 +104,8 @@ discard block |
||
| 104 | 104 | $command = Enum::INFO; |
| 105 | 105 | |
| 106 | 106 | return $this->dispatch(Builder::build($command, $section))->then(function ($value) { |
| 107 | - if ($value) { |
|
| 107 | + if ($value) |
|
| 108 | + { |
|
| 108 | 109 | $ret = explode("\r\n", $value); |
| 109 | 110 | $handled = []; |
| 110 | 111 | $lastKey = ''; |
@@ -117,7 +118,8 @@ discard block |
||
| 117 | 118 | $handled[$lastKey] = []; |
| 118 | 119 | continue; |
| 119 | 120 | } |
| 120 | - if ($v === '') { |
|
| 121 | + if ($v === '') |
|
| 122 | + { |
|
| 121 | 123 | continue; |
| 122 | 124 | } |
| 123 | 125 | if (($statMap = explode(':', $v)) && $statMap[0] && $statMap[1]) |
@@ -47,7 +47,8 @@ discard block |
||
| 47 | 47 | $command = Enum::BITFIELD; |
| 48 | 48 | $subCommand = strtoupper($subCommand); |
| 49 | 49 | //TODO: control flow improvement |
| 50 | - switch ($subCommand) { |
|
| 50 | + switch ($subCommand) |
|
| 51 | + { |
|
| 51 | 52 | case 'GET' : { |
| 52 | 53 | @list ($type, $offset) = $param; |
| 53 | 54 | $args = [$key, $subCommand, $type, $offset]; |
@@ -304,8 +305,10 @@ discard block |
||
| 304 | 305 | { |
| 305 | 306 | $command = Enum::MSET; |
| 306 | 307 | $args = []; |
| 307 | - if (!empty($kvMap)) { |
|
| 308 | - foreach ($kvMap as $key => $val) { |
|
| 308 | + if (!empty($kvMap)) |
|
| 309 | + { |
|
| 310 | + foreach ($kvMap as $key => $val) |
|
| 311 | + { |
|
| 309 | 312 | $args[] = $key; |
| 310 | 313 | $args[] = $val; |
| 311 | 314 | } |
@@ -322,8 +325,10 @@ discard block |
||
| 322 | 325 | { |
| 323 | 326 | $command = Enum::MSETNX; |
| 324 | 327 | $args = []; |
| 325 | - if (!empty($kvMap)) { |
|
| 326 | - foreach ($kvMap as $key => $val) { |
|
| 328 | + if (!empty($kvMap)) |
|
| 329 | + { |
|
| 330 | + foreach ($kvMap as $key => $val) |
|
| 331 | + { |
|
| 327 | 332 | $args[] = $key; |
| 328 | 333 | $args[] = $val; |
| 329 | 334 | } |
@@ -95,12 +95,14 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | $command = Enum::ZRANGE; |
| 97 | 97 | $args = [$key, $star, $stop]; |
| 98 | - if ($withScores) { |
|
| 98 | + if ($withScores) |
|
| 99 | + { |
|
| 99 | 100 | $args[] = 'WITHSCORES'; |
| 100 | 101 | return $this->dispatch(Builder::build($command, $args))->then(function ($value) { |
| 101 | 102 | $len = count($value); |
| 102 | 103 | $ret = []; |
| 103 | - for ($i=0; $i<$len; $i+=2) { |
|
| 104 | + for ($i=0; $i<$len; $i+=2) |
|
| 105 | + { |
|
| 104 | 106 | $ret[$value[$i]] = $value[$i+1]; |
| 105 | 107 | } |
| 106 | 108 | return $ret; |
@@ -144,10 +146,12 @@ discard block |
||
| 144 | 146 | { |
| 145 | 147 | $command = Enum::ZRANGEBYSCORE; |
| 146 | 148 | $args = [$key, $min, $max]; |
| 147 | - if ($withScores === true) { |
|
| 149 | + if ($withScores === true) |
|
| 150 | + { |
|
| 148 | 151 | $args[] = 'WITHSCORES'; |
| 149 | 152 | } |
| 150 | - if ($offset != 0 || $count != 0) { |
|
| 153 | + if ($offset != 0 || $count != 0) |
|
| 154 | + { |
|
| 151 | 155 | $args[] = 'LIMIT'; |
| 152 | 156 | $args[] = $offset; |
| 153 | 157 | $args[] = $count; |
@@ -156,9 +160,11 @@ discard block |
||
| 156 | 160 | |
| 157 | 161 | return $withScores ? $promise->then(function ($value) { |
| 158 | 162 | $len = is_array($value) ? count($value) : 0; |
| 159 | - if ($len > 0) { |
|
| 163 | + if ($len > 0) |
|
| 164 | + { |
|
| 160 | 165 | $ret = []; |
| 161 | - for ($i=0; $i<$len; $i+=2) { |
|
| 166 | + for ($i=0; $i<$len; $i+=2) |
|
| 167 | + { |
|
| 162 | 168 | $ret[$value[$i]] = $value[$i+1]; |
| 163 | 169 | } |
| 164 | 170 | |
@@ -241,15 +247,18 @@ discard block |
||
| 241 | 247 | $command = Enum::ZREVRANGE; |
| 242 | 248 | $args = [$key, $start, $stop]; |
| 243 | 249 | |
| 244 | - if ($withScores === true) { |
|
| 250 | + if ($withScores === true) |
|
| 251 | + { |
|
| 245 | 252 | $args[] = 'WITHSCORES'; |
| 246 | 253 | |
| 247 | 254 | return $this->dispatch(Builder::build($command, $args)) |
| 248 | 255 | ->then(function ($value) { |
| 249 | 256 | $len = is_array($value) ? count($value) : 0; |
| 250 | - if ($len > 0) { |
|
| 257 | + if ($len > 0) |
|
| 258 | + { |
|
| 251 | 259 | $ret = []; |
| 252 | - for ($i=0; $i<$len; $i+=2) { |
|
| 260 | + for ($i=0; $i<$len; $i+=2) |
|
| 261 | + { |
|
| 253 | 262 | $member = $value[$i]; |
| 254 | 263 | $score = $value[$i+1]; |
| 255 | 264 | $ret[$member] = $score; |
@@ -273,10 +282,12 @@ discard block |
||
| 273 | 282 | { |
| 274 | 283 | $command = Enum::ZREVRANGEBYSCORE; |
| 275 | 284 | $args = [$key, $max, $min]; |
| 276 | - if ($withScores === true) { |
|
| 285 | + if ($withScores === true) |
|
| 286 | + { |
|
| 277 | 287 | $args[] = 'WITHSCORES'; |
| 278 | 288 | } |
| 279 | - if ($offset != 0 || $count != 0) { |
|
| 289 | + if ($offset != 0 || $count != 0) |
|
| 290 | + { |
|
| 280 | 291 | $args[] = 'LIMIT'; |
| 281 | 292 | $args[] = $offset; |
| 282 | 293 | $args[] = $count; |
@@ -285,9 +296,11 @@ discard block |
||
| 285 | 296 | |
| 286 | 297 | return $withScores ? $promise->then(function ($value) { |
| 287 | 298 | $len = is_array($value) ? count($value) : 0; |
| 288 | - if ($len > 0) { |
|
| 299 | + if ($len > 0) |
|
| 300 | + { |
|
| 289 | 301 | $ret = []; |
| 290 | - for ($i=0; $i<$len; $i+=2) { |
|
| 302 | + for ($i=0; $i<$len; $i+=2) |
|
| 303 | + { |
|
| 291 | 304 | $ret[$value[$i]] = $value[$i+1]; |
| 292 | 305 | } |
| 293 | 306 | |