Commit Graph

134 Commits

Author SHA1 Message Date
Viktor Djupsjöbacka 6ea5b3e08b Fix argument count issue in HSET with associative array, update method signature for HSET and add documentation 2024-07-17 12:47:49 -07:00
michael-grunder 6673b5b2be SRANDMEMBER can return any type because of serialization. 2024-07-13 23:12:25 -07:00
Michael Grunder 99f9fd8353 Fix HRANDFIELD command when WITHVALUES is used. (#2524)
Redis requires the user to send a count if `WITHVALUES` is specified,
otherwise it sees the `WITHVALUES` argument as the count and will error
out that it's not a number.

We can also return false if the key doesn't exist.
2024-07-13 22:42:25 -07:00
michael-grunder 34b5bd81ef Rework how we declare ZSTD min/max constants.
Fixes #2487
2024-05-16 11:44:52 -07:00
divinity76 f865d5b95d fix missing <code> tags 2024-05-13 09:20:10 -07:00
Pavlo Yatsukhnenko 50e5405c03 Fix Arginfo / zpp mismatch for DUMP command 2024-03-25 19:28:29 +02:00
michael-grunder e52f0afaed Update SCAN to handle very large cursor values.
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
2024-03-17 10:59:14 -07:00
michael-grunder fa1a283ac9 Fix some typos 2024-03-13 13:46:58 -07:00
Benjamin Morel 77ab62bccb Tighter return types for Redis::(keys|hKeys|hVals|hGetAll)() 2024-02-21 13:17:23 -08:00
Viktor Szépe 37c5f8d451 Fix typos 2024-02-21 13:16:12 -08:00
michael-grunder ed7c9f6f63 Implement WAITAOF command. 2024-02-14 12:03:29 -08:00
Takayasu Oyama 8f8ff72a79 Update zCount argument type in redis.stub.php (#2439)
* Update zCount argument type in redis.stub.php

zCount's min/max can also be an integer.

* fix arginfo
2024-01-24 12:46:50 -08:00
Pavlo Yatsukhnenko 5d293245cd Fix Redis::mget signature 2024-01-16 13:43:51 -08:00
Uładzimir Tsykun df074dbe9e the VALUE argument type for hSetNx must be the same as for hSet 2023-10-30 10:51:23 -07:00
Pavlo Yatsukhnenko 95bd184be9 Update redis.stub.php 2023-09-17 10:26:42 +03:00
Nicolas Grekas 5e4bdf97c8 Fix arginfo for arguments that default to null 2023-07-27 17:57:44 +02:00
michael-grunder ccd419a4c8 Small refactor of some methods
* Use our `redis_cmd_append_sstr_key_*` and `redis_cmd_append_sstr_zval`
  wrappers, which handle key prefixing and serialization transparently.

* Rework ZADD so it can handle the bulk double response from the `INCR`
  options.
2023-03-01 11:45:47 -08:00
Pavlo Yatsukhnenko 7c46ad2c05 Issue #2068
Add FCALL/FCALL_RO commands
2022-12-24 13:37:50 +02:00
Pavlo Yatsukhnenko 90a0e9cc0e Add Redis::function command 2022-12-18 18:21:42 +02:00
michael-grunder aa0938a4e2 Rework ZRANGE argument handling.
Rework argument parsing for `ZRANGE` so we can pass either a string or
an integer so everything will work even when using strict types.

Additionally update our docs to use the correct mechanism for adding
the `BYSCORE` option.

Fixes #2291
2022-12-10 12:00:09 -08:00
michael-grunder 19fd7e0c00 Refactor PFCOUNT command. 2022-12-10 11:58:08 -08:00
michael-grunder 121e9d9c29 Implement BLMOVE and add LMOVE/BLMOVE to cluster.
* Refactor `redis_lmove_cmd` to work for both `LMOVE` and `BLMOVE`
* Implement `LMOVE` and `BLMOVE` in RedisCluster.

See #1894
2022-12-01 13:48:03 -08:00
Pavlo Yatsukhnenko 7644736e13 Issue #2068, ssubscribe/sunsubscribe 2022-12-01 22:19:15 +02:00
michael-grunder 90828019de Refactor network IO tracking.
* Create inline wrappers of the low-level php_stream_* functions that
  also keep track of the number of bytes written/read.

* Change the logic to aggregate network traffic until the user
  explicitly "resets" it.  I think this will be a more common use-case
  (running many commands and then seeing overall network IO).

See #2106
2022-11-25 13:41:47 -08:00
michael-grunder 2a6dee5d4d Use PHP's new class constant mechanism.
Let gen_stub.php define the constants for us, including deriving their
actual values from C defines.

As a side-effect we have to drop support for PHP < 7.2 as it does not
have interned strings.
2022-11-24 09:26:44 -08:00
Pavlo Yatsukhnenko ff863f3f97 Refactor command command
Issue #2068
2022-11-19 14:04:38 +02:00
michael-grunder 872b69313b Documentation: Normalize formatting. 2022-11-18 00:02:16 -08:00
michael-grunder 0b7bd83f57 Add more docblocks and fix XAUTOCLAIM response handler.
- Finish adding docblocks with examples for all of the stream commands.
- Fix XAUTOCLAIM response handler (the reply has a slightly different
  structure to XCLAIM.
2022-11-15 23:29:45 -08:00
michael-grunder c14a9e3a01 Documentation: Normalize examples. 2022-11-15 18:16:57 -08:00
michael-grunder 53d142d93a Documentation: Add more docblocks and fix up formatting. 2022-11-15 15:09:24 -08:00
michael-grunder 2d365ee2ad Documentation: Format docs and add remaining GEO* docblocks 2022-11-15 11:26:29 -08:00
michael-grunder ef4699c726 Documentation: Rework more formatting and add example sections.
[skip ci]
2022-11-10 19:36:06 -08:00
michael-grunder 71758b091b Update stubs. 2022-11-09 19:24:47 -08:00
Michael Grunder 87fa36d6c7 Documentation: Formatting for setOption (#2250) 2022-11-09 13:55:15 -08:00
michael-grunder 6d595b35e9 Fix xtrim stub
[no ci]
2022-11-08 14:11:08 -08:00
michael-grunder 450904f75c Documentation: More docblocks with examples. 2022-11-07 18:17:48 -08:00
michael-grunder 17db23281a Documentation: Several more docblocks 2022-11-07 16:45:57 -08:00
michael-grunder f05ba81935 Documentation: Add several more docblocs
- Add a bunch more docblocks with examples
- Link every relevant RedisCluster method to the Redis docs.
2022-11-07 11:02:31 -08:00
michael-grunder cf63e96ec5 Documentation: More docblocks 2022-11-03 20:40:39 -07:00
michael-grunder a5c4790114 Documentation: More command docblocks 2022-11-03 17:47:21 -07:00
michael-grunder 854f3aa426 Documentation: Stream doc blocks and xtrim fix
- XTRIM needs to take the `$threshold` arg as a string since MINID is
  not a number.
2022-11-03 14:32:07 -07:00
michael-grunder b8679d7af1 Documentation: Several ZSET docblocks 2022-11-01 23:07:21 -07:00
michael-grunder bb06ffa380 Documentation: Even more docblocks 2022-11-01 16:38:23 -07:00
michael-grunder 980ea6b154 Documentation: More docblocks with examples
[skip ci]
2022-11-01 14:13:17 -07:00
michael-grunder b04684d442 Documentation: More docblocks with examples
[skip ci]
2022-11-01 12:23:38 -07:00
michael-grunder 70a55f3ef9 Documentation: More docblocks for eventual
[skip ci]
2022-11-01 11:05:38 -07:00
michael-grunder 9934088926 Documentation: Add several more docblocks. 2022-11-01 10:53:47 -07:00
michael-grunder f2cef8be06 More docblocks and refactor SLAVEOF command.
Add additional complete docblocks for a few more commands.

Refactor SLAVEOF handler to conform with more modern PhpRedis command
handlers.

Create REPLICAOF and deprecate SLAVEOF as Redis has done since 5.0.0.
2022-10-31 22:32:43 -07:00
michael-grunder 7d5db510a0 Documentation: SSCAN docblock and example
[skip ci]
2022-10-31 20:45:18 -07:00
michael-grunder 0dd2836f3c Documentation: Add a docblock for the set command. 2022-10-31 17:47:17 -07:00