375 Commits

Author SHA1 Message Date
Jakub Onderka 99650e1545 Avoid unnecessary allocation in redis_key_varval_cmd
This will slightly reduce memory usage for commands like RPUSH, LPUSH, SADD, SREM, etc
2024-11-26 18:28:09 -08:00
Jakub Onderka f6906470a5 Use zval_get_tmp_string method that is faster when provided zval is string 2024-11-26 18:28:09 -08:00
Jakub Onderka 83a19656f4 Faster parameter parsing in redis_key_cmd and redis_key_long_val_cmd 2024-11-26 10:39:23 -08:00
michael-grunder 4cd3f59356 Implement KeyDB's EXPIREMEMBER[AT] commands 2024-11-15 08:59:10 -08:00
michael-grunder 0fe45d24d4 Fix XAUTOCLAIM argc when sending COUNT
Add 2 to argc not 1 + count when sending a specific COUNT.
2024-10-17 08:21:54 -07:00
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 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 981c69314d Add GETEX to README docs + minor change to command.
* Adds `GETEX` to the README.md documentation.
* Allow the user to send `PERSIST` either as an array key or just in the
  array, to conform with similar methods.
* Implement getEx for `RedisCluster`

Fixes #2512
2024-06-20 13:56:17 -07:00
Pavlo Yatsukhnenko 7c551424b6 Refactor redis_script_cmd
- Update redis_script_cmd to use redis_build_script_cmd.
- Fix condition for parsing sync/async arguments of flush sub-command.
2024-06-20 21:05:20 +03:00
michael-grunder fa1a283ac9 Fix some typos 2024-03-13 13:46:58 -07:00
michael-grunder 732e466a6a Improve warning when we encounter an invalid EXPIRY in SET
We actually had two different bits of logic to handle EXPIRY values in
the `SET` command.  One for the legacy `SET` -> `SETEX` mapping and
another for the newer `SET foo bar EX <expiry>`.

Additionally the error message could be confusing.  Passing 3.1415 for
an `EX` expiry would fail as we didn't allow floats.

This commit consolidates expiry parsing to our existing helper function
as well as improves the `php_error_docref` warning in the event that the
user passes invalid data.  The warning will now tell the user the type
they tried to pass as an EXPIRY to make it easier to track down what's
going wrong.

Fixes #2448
2024-02-21 13:16:36 -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
michael-grunder 2f276dcd37 Find our callback by pattern with PSUBSCRIBE
* Use the pattern Redis provides us not the channel, if this is
a wildcard based `PSUBSCRIBE` payload.

* Don't test whether our slots match in `SSUBSCRIBE` when not in cluster
  mode.

Fixes #2395
2023-09-26 11:29:04 -07:00
Pavlo Yatsukhnenko 264c0c7ea4 Fix unknown expiration modifier warning when null argument passed 2023-09-17 10:17:05 +03:00
Remi Collet 715012b2c1 fix C99 usages 2023-08-02 16:07:21 +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 b193a6d051 Merge pull request #2308 from phpredis/issue-2068-fcall
Issue #2068
2022-12-30 11:26:30 +02:00
Pavlo Yatsukhnenko 77c4f7a36b Refactor CLIENT command 2022-12-26 14:56:05 +02:00
Pavlo Yatsukhnenko 7c46ad2c05 Issue #2068
Add FCALL/FCALL_RO commands
2022-12-24 13:37:50 +02:00
Pavlo Yatsukhnenko 2908215572 Merge pull request #2306 from phpredis/issue-2068-function
Add Redis::function command
2022-12-21 22:53:16 +02:00
Pavlo Yatsukhnenko 90a0e9cc0e Add Redis::function command 2022-12-18 18:21:42 +02:00
michael-grunder bb66a54772 Refactor HMGET command
Use new argument parsing API and simplify logic.
2022-12-12 21:24:42 -08:00
michael-grunder 40e1b1bfe8 Migrate more command handlers to the new arg API 2022-12-11 22:37:25 -08:00
michael-grunder c8224b93b1 Refactor a more command handlers.
Use PHP's new argument parsing API and also our simplified mechanism for
dynamically appending strings or packed values.
2022-12-11 22:37:07 -08:00
michael-grunder 5b560ccfd7 Refactor a couple more command methods.
Use the new argument parsing API
2022-12-10 12:00:32 -08:00
michael-grunder 15347c7d87 Fix CodeQL confusion. 2022-12-10 12:00:09 -08: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 204a02c5fa Refactor SMOVE command. 2022-12-10 11:58:32 -08:00
michael-grunder 19fd7e0c00 Refactor PFCOUNT command. 2022-12-10 11:58:08 -08:00
michael-grunder 90eb04709a Refactor HMSET command. 2022-12-10 11:57:42 -08:00
michael-grunder 6d10448109 Refactor MSET and MSETNX commands.
Switch to using our normal command handling logic for MSET and MSETNX.
2022-12-10 11:57:24 -08:00
michael-grunder 3574ef0867 Refactor INFO and SCRIPT commands.
Use `gen_varkey_cmd` for INFO and SCRIPT.
2022-12-10 11:45:08 -08:00
michael-grunder 8cb6dd17fe Refactor MGET command. 2022-12-07 11:18:25 -08:00
michael-grunder 121d330c16 Remove min_argc indirection all together.
Given how `gen_varkey_cmd` is called, we can actually derive the
`min_argc` from whether or not it has a timeout.
2022-12-07 11:18:08 -08:00
michael-grunder 4264940e52 Parentheses. 2022-12-07 11:18:08 -08:00
michael-grunder 486f131f44 Clearer logic for checking if we have a single array. 2022-12-07 11:18:08 -08:00
michael-grunder 3efa59cbc1 Refactor gen_varkey_cmd
Use the new argument parsing API which lets us avoid an allocation
and switch to redis_cmd_append_sstr_key_zval to abstract away key
prefixing logic.
2022-12-07 11:18:08 -08:00
michael-grunder acb5db7661 Refactor OBJECT command. 2022-12-06 12:42:29 -08:00
michael-grunder e90557c832 Silence CodeQL false positive. 2022-12-06 10:46:32 -08:00
michael-grunder f62363c2a3 Refactor SRANDMEMBER command. 2022-12-06 10:46:32 -08:00
michael-grunder 86f15ccaa1 Refactor SELECT command.
* Use our common command handler logic for SELECT.

* Shift updating `redis_sock->dbNumber` from the command itself to the
  reply handler, so we aren't erroneously pointing to a non-existent
  database before the command succeeds.
2022-12-06 10:46:17 -08:00
michael-grunder 79c9d2241f Refactor rawCommand and WAIT 2022-12-03 23:32:24 -08:00
michael-grunder 27900f39d2 Implement new ZSET commands for cluster
* Implement `ZDIFF`, `ZINTER`, `ZUNION`, `ZMSCORE`, and
  `ZRANDMEMBER` for `RedisCluster`.
* Refactor `ZUNIONSTORE` command and switch to using our centralized
  zset option parsing handler.

See #1894
2022-12-02 09:11:00 -08:00
michael-grunder 40a2c254e2 Implement COPY for RedisCluster
* Refactor `redis_copy_cmd` to use the new argument parsing macros.
* Add a handler in `RedisCluster`.

See #1894
2022-12-01 22:38:19 -08:00
Michael Grunder fa5d1af9ff Implement GEOSEARCH and GEOSEARCHSTORE for RedisCluster. (#2277)
* Implement GEOSEARCH and GEOSEARCHSTORE for RedisCluster.

See #1894
2022-12-01 21:54:15 -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
Pavlo Yatsukhnenko ff863f3f97 Refactor command command
Issue #2068
2022-11-19 14:04:38 +02: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