Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f9436e2

Browse files
committed
[WIP] Issue #1894
Add NOMKSTREAM option to XADD command.
1 parent 552f41a commit f9436e2

4 files changed

Lines changed: 14 additions & 7 deletions

File tree

redis.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ public function wait(int $count, int $timeout): int;
461461

462462
public function xack(string $key, string $group, array $ids): int;
463463

464-
public function xadd(string $key, string $id, array $values, int $maxlen = 0, bool $approx = false): string;
464+
public function xadd(string $key, string $id, array $values, int $maxlen = 0, bool $approx = false, bool $nomkstream = false): string;
465465

466466
public function xclaim(string $key, string $group, string $consumer, int $min_iddle, array $ids, array $options): string|array;
467467

redis_arginfo.h

Lines changed: 2 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: de74da38c8a832457554c3a0e1e042d47464e36c */
2+
* Stub hash: 49b5dded8c4ca8f50f0427d203e35c89278ad364 */
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, 0, "null")
@@ -748,6 +748,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_xadd, 0, 3, IS_STRIN
748748
ZEND_ARG_TYPE_INFO(0, values, IS_ARRAY, 0)
749749
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxlen, IS_LONG, 0, "0")
750750
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, approx, _IS_BOOL, 0, "false")
751+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, nomkstream, _IS_BOOL, 0, "false")
751752
ZEND_END_ARG_INFO()
752753

753754
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Redis_xclaim, 0, 6, MAY_BE_STRING|MAY_BE_ARRAY)

redis_commands.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3810,15 +3810,16 @@ int redis_xadd_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
38103810
zend_string *arrkey;
38113811
zval *z_fields, *value;
38123812
zend_long maxlen = 0;
3813-
zend_bool approx = 0;
3813+
zend_bool approx = 0, nomkstream = 0;
38143814
zend_ulong idx;
38153815
HashTable *ht_fields;
38163816
int fcount, argc;
38173817
char *key, *id;
38183818
size_t keylen, idlen;
38193819

3820-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssa|lb", &key, &keylen,
3821-
&id, &idlen, &z_fields, &maxlen, &approx) == FAILURE)
3820+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssa|lbb", &key, &keylen,
3821+
&id, &idlen, &z_fields, &maxlen, &approx,
3822+
&nomkstream) == FAILURE)
38223823
{
38233824
return FAILURE;
38243825
}
@@ -3838,12 +3839,16 @@ int redis_xadd_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
38383839
/* Calculate argc for XADD. It's a bit complex because we've got
38393840
* an optional MAXLEN argument which can either take the form MAXLEN N
38403841
* or MAXLEN ~ N */
3841-
argc = 2 + (fcount*2) + (maxlen > 0 ? (approx ? 3 : 2) : 0);
3842+
argc = 2 + nomkstream + (fcount * 2) + (maxlen > 0 ? (approx ? 3 : 2) : 0);
38423843

38433844
/* XADD key ID field string [field string ...] */
38443845
REDIS_CMD_INIT_SSTR_STATIC(&cmdstr, argc, "XADD");
38453846
redis_cmd_append_sstr_key(&cmdstr, key, keylen, redis_sock, slot);
38463847

3848+
if (nomkstream) {
3849+
REDIS_CMD_APPEND_SSTR_STATIC(&cmdstr, "NOMKSTREAM");
3850+
}
3851+
38473852
/* Now append our MAXLEN bits if we've got them */
38483853
if (maxlen > 0) {
38493854
REDIS_CMD_APPEND_SSTR_STATIC(&cmdstr, "MAXLEN");

redis_legacy_arginfo.h

Lines changed: 2 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: de74da38c8a832457554c3a0e1e042d47464e36c */
2+
* Stub hash: 49b5dded8c4ca8f50f0427d203e35c89278ad364 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
55
ZEND_ARG_INFO(0, options)
@@ -664,6 +664,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_xadd, 0, 0, 3)
664664
ZEND_ARG_INFO(0, values)
665665
ZEND_ARG_INFO(0, maxlen)
666666
ZEND_ARG_INFO(0, approx)
667+
ZEND_ARG_INFO(0, nomkstream)
667668
ZEND_END_ARG_INFO()
668669

669670
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_xclaim, 0, 0, 6)

0 commit comments

Comments
 (0)