Implement VSIM command

This command is similar to `VADD` in that it's pretty simple but allows
for a great many options.

In it's most basic form:

```php
// To get similarity of a different element
$redis->vsim('myvec', 'some-element');

// To get similarity for a vector of scores
```

As seen above the method attempts to infer element or vector from the
argument passed to $member`. However, since we do serialize the member
when doing `ELE` mode, the user can also specify `ELE` explicitly in the
options array to force an `ELE` search sending serialized values.

```php
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
$redis->vsim('myvec', [3.14, 2.71], ['ELE']);
```

See #2543
This commit is contained in:
michael-grunder
2025-07-30 13:33:24 -07:00
committed by Michael Grunder
parent 286fa63064
commit d1d690053f
11 changed files with 331 additions and 4 deletions
+6
View File
@@ -1058,6 +1058,12 @@ class RedisCluster {
*/
public function vadd(string $key, array $values, mixed $element, array|null $options = null): RedisCluster|int|false;
/**
* @see Redis::vsim
*/
public function vsim(string $key, mixed $member, array|null $options = null): Redis|array|false;
/**
* @see Redis::xack
*/