| @@ 143-170 (lines=28) @@ | ||
| 140 | * @override |
|
| 141 | * @inheritDoc |
|
| 142 | */ |
|
| 143 | public function zRangeByScore($key, $min, $max, $withScores = false, $offset = 0, $count = 0) |
|
| 144 | { |
|
| 145 | $command = Enum::ZRANGEBYSCORE; |
|
| 146 | $args = [$key, $min, $max]; |
|
| 147 | if ($withScores === true) { |
|
| 148 | $args[] = 'WITHSCORES'; |
|
| 149 | } |
|
| 150 | if ($offset != 0 || $count != 0) { |
|
| 151 | $args[] = 'LIMIT'; |
|
| 152 | $args[] = $offset; |
|
| 153 | $args[] = $count; |
|
| 154 | } |
|
| 155 | $promise = $this->dispatch(Builder::build($command, $args)); |
|
| 156 | ||
| 157 | return $withScores ? $promise->then(function ($value) { |
|
| 158 | $len = is_array($value) ? count($value) : 0; |
|
| 159 | if ($len > 0) { |
|
| 160 | $ret = []; |
|
| 161 | for ($i=0; $i<$len; $i+=2) { |
|
| 162 | $ret[$value[$i]] = $value[$i+1]; |
|
| 163 | } |
|
| 164 | ||
| 165 | return $ret; |
|
| 166 | } |
|
| 167 | ||
| 168 | return $value; |
|
| 169 | } ) : $promise; |
|
| 170 | } |
|
| 171 | ||
| 172 | /** |
|
| 173 | * @override |
|
| @@ 272-299 (lines=28) @@ | ||
| 269 | * @override |
|
| 270 | * @inheritDoc |
|
| 271 | */ |
|
| 272 | public function zRevRangeByScore($key, $max, $min, $withScores = false, $offset = 0, $count = 0) |
|
| 273 | { |
|
| 274 | $command = Enum::ZREVRANGEBYSCORE; |
|
| 275 | $args = [$key, $max, $min]; |
|
| 276 | if ($withScores === true) { |
|
| 277 | $args[] = 'WITHSCORES'; |
|
| 278 | } |
|
| 279 | if ($offset != 0 || $count != 0) { |
|
| 280 | $args[] = 'LIMIT'; |
|
| 281 | $args[] = $offset; |
|
| 282 | $args[] = $count; |
|
| 283 | } |
|
| 284 | $promise = $this->dispatch(Builder::build($command, $args)); |
|
| 285 | ||
| 286 | return $withScores ? $promise->then(function ($value) { |
|
| 287 | $len = is_array($value) ? count($value) : 0; |
|
| 288 | if ($len > 0) { |
|
| 289 | $ret = []; |
|
| 290 | for ($i=0; $i<$len; $i+=2) { |
|
| 291 | $ret[$value[$i]] = $value[$i+1]; |
|
| 292 | } |
|
| 293 | ||
| 294 | return $ret; |
|
| 295 | } |
|
| 296 | ||
| 297 | return $value; |
|
| 298 | } ) : $promise; |
|
| 299 | } |
|
| 300 | ||
| 301 | /** |
|
| 302 | * @override |
|