mirror of
https://github.com/php-win-ext/phpredis.git
synced 2026-03-24 17:12:15 +01:00
Technically Redis may return any unsigned 64 bit integer as a scan
cursor. This presents a problem for PHP in that PHP's integers are
signed. Because of that if a scan cursor is > 2^63 it will overflow and
fail to work properly.
This commit updates our SCAN family of commands to deliver cursors in
their string form.
```php
public function scan(null|int|string $iterator, ...);
```
On initial entry into our SCAN family we convert either a NULL or empty
string cursor to zero, and send the initial scan command.
As Redis replies with cursors we either represent them as a long (if
they are <= ZEND_ULONG_MAX) and as a string if greater. This should
mean the fix is minimally breaking as the following code will still
work:
```php
$it = NULL;
do {
print_r($redis->scan($it));
} while ($it !== 0);
```
The `$it !== 0` still works because the zero cursor will be represented
as an integer. Only absurdly large (> 2^63) values are represented as a
string.
Fixes #2454
73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @generate-function-entries
|
|
* @generate-legacy-arginfo
|
|
* @generate-class-entries
|
|
*/
|
|
|
|
class RedisArray {
|
|
|
|
public function __call(string $function_name, array $arguments): mixed;
|
|
|
|
public function __construct(string|array $name_or_hosts, ?array $options = null);
|
|
|
|
public function _continuum(): bool|array;
|
|
|
|
public function _distributor(): bool|callable;
|
|
|
|
public function _function(): bool|callable;
|
|
|
|
public function _hosts(): bool|array;
|
|
|
|
public function _instance(string $host): bool|null|Redis;
|
|
|
|
public function _rehash(?callable $fn = null): bool|null;
|
|
|
|
public function _target(string $key): bool|string|null;
|
|
|
|
public function bgsave(): array;
|
|
|
|
public function del(string|array $key, string ...$otherkeys): bool|int;
|
|
|
|
public function discard(): bool|null;
|
|
|
|
public function exec(): bool|null|array;
|
|
|
|
public function flushall(): bool|array;
|
|
|
|
public function flushdb(): bool|array;
|
|
|
|
public function getOption(int $opt): bool|array;
|
|
|
|
public function hscan(string $key, null|int|string &$iterator, ?string $pattern = null, int $count = 0): bool|array;
|
|
|
|
public function info(): bool|array;
|
|
|
|
public function keys(string $pattern): bool|array;
|
|
|
|
public function mget(array $keys): bool|array;
|
|
|
|
public function mset(array $pairs): bool;
|
|
|
|
public function multi(string $host, ?int $mode = null): bool|RedisArray;
|
|
|
|
public function ping(): bool|array;
|
|
|
|
public function save(): bool|array;
|
|
|
|
public function scan(null|int|string &$iterator, string $node, ?string $pattern = null, int $count = 0): bool|array;
|
|
|
|
public function select(int $index): bool|array;
|
|
|
|
public function setOption(int $opt, string $value): bool|array;
|
|
|
|
public function sscan(string $key, null|int|string &$iterator, ?string $pattern = null, int $count = 0): bool|array;
|
|
|
|
public function unlink(string|array $key, string ...$otherkeys): bool|int;
|
|
|
|
public function unwatch(): bool|null;
|
|
|
|
public function zscan(string $key, null|int|string &$iterator, ?string $pattern = null, int $count = 0): bool|array;
|
|
}
|