Implement VADD command

This is for Redis 8.0's vector sets.

The command itself can be quite complex with all of the various options but
pretty simple using all defaults.

```php
$redis->vadd('myvec', [3.14, 2.17], 'myelement');
```

The implementation takes a default argument `$options` which can be an array in
order to specify the myriad of other knobs users can send. We just do a bit of
validation on inputs (e.g. certain numeric options must be positive) and make
sure the command is constructed in a valid way (e.g. REDUCE <dim> must come
before the floating point values).

By default we deliver `FP32` blobs but allow the user to send `VALUES` in the
options array which will cause PhpRedis to send N individual values. Sending
values is slower but might be nice for debugging (e.g. watching monitor)

See #2543
This commit is contained in:
michael-grunder
2025-07-29 14:02:39 -07:00
committed by Michael Grunder
parent 9cae7815da
commit 286fa63064
12 changed files with 356 additions and 4 deletions

View File

@@ -1053,6 +1053,11 @@ class RedisCluster {
*/
public function watch(string $key, string ...$other_keys): RedisCluster|bool;
/**
* @see Redis::vadd
*/
public function vadd(string $key, array $values, mixed $element, array|null $options = null): RedisCluster|int|false;
/**
* @see Redis::xack
*/