Skip to content

Commit 0ed0fc0

Browse files
Add Redis::REDIS_VECTORSET type.
Redis >= 8.0 has a new type `vectorset` that we should support like all the other types.
1 parent 659dc76 commit 0ed0fc0

8 files changed

Lines changed: 38 additions & 4 deletions

File tree

cluster_library.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ PHP_REDIS_API void cluster_long_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster
19481948

19491949
/* TYPE response handler */
19501950
PHP_REDIS_API void cluster_type_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
1951-
void *ctx)
1951+
void *ctx)
19521952
{
19531953
// Make sure we got the right kind of response
19541954
if (c->reply_type != TYPE_LINE) {
@@ -1968,7 +1968,10 @@ PHP_REDIS_API void cluster_type_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster
19681968
CLUSTER_RETURN_LONG(c, REDIS_ZSET);
19691969
} else if (redis_strncmp(c->line_reply, ZEND_STRL("stream")) == 0) {
19701970
CLUSTER_RETURN_LONG(c, REDIS_STREAM);
1971+
} else if (redis_strncmp(c->line_reply, ZEND_STRL("vectorset")) == 0) {
1972+
CLUSTER_RETURN_LONG(c, REDIS_VECTORSET);
19711973
} else {
1974+
19721975
CLUSTER_RETURN_LONG(c, REDIS_NOT_FOUND);
19731976
}
19741977
}

common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ typedef enum {
6161
#define REDIS_ZSET 4
6262
#define REDIS_HASH 5
6363
#define REDIS_STREAM 6
64+
#define REDIS_VECTORSET 7
6465

6566
#ifdef PHP_WIN32
6667
#define PHP_REDIS_API __declspec(dllexport)

library.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,8 @@ PHP_REDIS_API int redis_type_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *r
12391239
l = REDIS_HASH;
12401240
} else if (redis_strncmp(response, ZEND_STRL("+stream")) == 0) {
12411241
l = REDIS_STREAM;
1242+
} else if (redis_strncmp(response, ZEND_STRL("+vectorset")) == 0) {
1243+
l = REDIS_VECTORSET;
12421244
} else {
12431245
l = REDIS_NOT_FOUND;
12441246
}

redis.stub.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ class Redis {
6363
*/
6464
public const REDIS_STREAM = UNKNOWN;
6565

66+
/**
67+
*
68+
* @var int
69+
* @cvalue REDIS_VECTORSET
70+
*
71+
*/
72+
public const REDIS_VECTORSET = UNKNOWN;
73+
6674
/**
6775
*
6876
* @var int
@@ -3733,6 +3741,7 @@ public function ttl(string $key): Redis|int|false;
37333741
* Redis::REDIS_ZSET
37343742
* Redis::REDIS_HASH
37353743
* Redis::REDIS_STREAM
3744+
* Redis::REDIS_VECTORSET
37363745
*
37373746
* @example
37383747
* foreach ($redis->keys('*') as $key) {

redis_arginfo.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: d5f56120b09dc6a8240d87efa53dc5749c031f38 */
2+
* Stub hash: e1643951a097b7a2f1bb3c0b6afd2c29f746a0d6 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null")
@@ -1856,6 +1856,12 @@ static zend_class_entry *register_class_Redis(void)
18561856
zend_declare_class_constant_ex(class_entry, const_REDIS_STREAM_name, &const_REDIS_STREAM_value, ZEND_ACC_PUBLIC, NULL);
18571857
zend_string_release(const_REDIS_STREAM_name);
18581858

1859+
zval const_REDIS_VECTORSET_value;
1860+
ZVAL_LONG(&const_REDIS_VECTORSET_value, REDIS_VECTORSET);
1861+
zend_string *const_REDIS_VECTORSET_name = zend_string_init_interned("REDIS_VECTORSET", sizeof("REDIS_VECTORSET") - 1, 1);
1862+
zend_declare_class_constant_ex(class_entry, const_REDIS_VECTORSET_name, &const_REDIS_VECTORSET_value, ZEND_ACC_PUBLIC, NULL);
1863+
zend_string_release(const_REDIS_VECTORSET_name);
1864+
18591865
zval const_ATOMIC_value;
18601866
ZVAL_LONG(&const_ATOMIC_value, ATOMIC);
18611867
zend_string *const_ATOMIC_name = zend_string_init_interned("ATOMIC", sizeof("ATOMIC") - 1, 1);

redis_legacy_arginfo.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: d5f56120b09dc6a8240d87efa53dc5749c031f38 */
2+
* Stub hash: e1643951a097b7a2f1bb3c0b6afd2c29f746a0d6 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
55
ZEND_ARG_INFO(0, options)
@@ -1694,6 +1694,12 @@ static zend_class_entry *register_class_Redis(void)
16941694
zend_declare_class_constant_ex(class_entry, const_REDIS_STREAM_name, &const_REDIS_STREAM_value, ZEND_ACC_PUBLIC, NULL);
16951695
zend_string_release(const_REDIS_STREAM_name);
16961696

1697+
zval const_REDIS_VECTORSET_value;
1698+
ZVAL_LONG(&const_REDIS_VECTORSET_value, REDIS_VECTORSET);
1699+
zend_string *const_REDIS_VECTORSET_name = zend_string_init_interned("REDIS_VECTORSET", sizeof("REDIS_VECTORSET") - 1, 1);
1700+
zend_declare_class_constant_ex(class_entry, const_REDIS_VECTORSET_name, &const_REDIS_VECTORSET_value, ZEND_ACC_PUBLIC, NULL);
1701+
zend_string_release(const_REDIS_VECTORSET_name);
1702+
16971703
zval const_ATOMIC_value;
16981704
ZVAL_LONG(&const_ATOMIC_value, ATOMIC);
16991705
zend_string *const_ATOMIC_name = zend_string_init_interned("ATOMIC", sizeof("ATOMIC") - 1, 1);

tests/RedisClusterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,8 @@ protected function keyTypeToString($key_type) {
658658
return "hash";
659659
case Redis::REDIS_STREAM:
660660
return "stream";
661+
case Redis::REDIS_VECTORSET:
662+
return "vectorset";
661663
default:
662664
return "unknown($key_type)";
663665
}

tests/RedisTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,10 +1155,15 @@ public function testType() {
11551155
$this->assertEquals(Redis::REDIS_STREAM, $this->redis->type('stream'));
11561156
}
11571157

1158+
if ($this->haveCommand('vadd')) {
1159+
$this->redis->del('vset');
1160+
$this->assertEquals(1, $this->redis->vadd('vset', [1.5, 2.5], 'foo'));
1161+
$this->assertEquals(Redis::REDIS_VECTORSET, $this->redis->type('vset'));
1162+
}
1163+
11581164
// None
11591165
$this->redis->del('keyNotExists');
11601166
$this->assertEquals(Redis::REDIS_NOT_FOUND, $this->redis->type('keyNotExists'));
1161-
11621167
}
11631168

11641169
public function testStr() {

0 commit comments

Comments
 (0)