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