Implement VEMB and slightly rework VINFO

Unfortunately `VEMB` has a unique `RESP2` reply as far as I can tell,
where it sends the embedding mode (int8, bin, fp32) as a simple string.

This would cause any of PhpRedis' generic reply handlers to turn that
into `true` which isn't useful. For that reason we need a custom reply
handler.

Additionally slightly rework `VINFO` to short circuit and return failure
if we read anything other than a bulk string or an integer reply type.
Otherwise we may get out of sync on the socket.

See #2543
This commit is contained in:
michael-grunder
2025-07-31 12:50:29 -07:00
committed by Michael Grunder
parent 8f8a49bec2
commit 96378b70fd
13 changed files with 194 additions and 15 deletions
+19
View File
@@ -7754,6 +7754,25 @@ class Redis_Test extends TestSuite {
$this->assertEquals(1, $this->redis->del('v'));
}
public function testVEmb() {
if ( ! $this->minVersionCheck('8.0'))
$this->markTestSkipped();
$this->assertIsInt($this->redis->del('v'));
$this->assertEquals(1, $this->redis->vadd('v', [0.5, 1.0], 'e'));
$res = $this->redis->vemb('v', 'e');
$this->assertIsArray($res);
$this->assertTrue(filter_var($res[0], FILTER_VALIDATE_FLOAT) !== false);
$res = $this->redis->vemb('v', 'e', true);
$this->assertIsArray($res);
$this->assertEquals('int8', $res[0]);
$this->assertEquals(1, $this->redis->del('v'));
}
public function testInvalidAuthArgs() {
$client = $this->newInstance();