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

Skip to content

Commit dc1f239

Browse files
TOUCH command
Implement the TOUCH command and refactor several of our "variadic key" commands, which were previously all using their own specific handlers. While refactoring the code, I changed `EXISTS` to require one key (it had previously been set to require zero keys). Additonally, it looks like we had a disparity in two commands which should be idential to PhpRedis: SINTERSTORE and SUNIONSTORE. Previously, SINTERSTORE required only one argument but SUNIONSTORE 2. I simply changed SUNIONSTORE to also only require a single argument, since that argument could be an array. ```php $redis->sInterStore(['dst', 'src1', 'src2']); $redis->sUnionStore(['dst', 'src1', 'src2']); ```
1 parent 69355fa commit dc1f239

11 files changed

Lines changed: 111 additions & 143 deletions

redis.c

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,27 +1043,32 @@ PHP_METHOD(Redis, mget)
10431043
REDIS_PROCESS_RESPONSE(redis_sock_read_multibulk_reply);
10441044
}
10451045

1046-
/* {{{ proto boolean Redis::exists(string key)
1046+
/* {{{ proto boolean Redis::exists(string $key, string ...$more_keys)
10471047
*/
1048-
PHP_METHOD(Redis, exists)
1049-
{
1050-
REDIS_PROCESS_CMD(exists, redis_long_response);
1048+
PHP_METHOD(Redis, exists) {
1049+
REDIS_PROCESS_KW_CMD("EXISTS", redis_varkey_cmd, redis_long_response);
10511050
}
10521051
/* }}} */
10531052

1053+
/* {{{ proto boolean Redis::touch(string $key, string ...$more_keys)
1054+
*/
1055+
PHP_METHOD(Redis, touch) {
1056+
REDIS_PROCESS_KW_CMD("TOUCH", redis_varkey_cmd, redis_long_response);
1057+
}
1058+
1059+
/* }}} */
10541060
/* {{{ proto boolean Redis::del(string key)
10551061
*/
1056-
PHP_METHOD(Redis, del)
1057-
{
1058-
REDIS_PROCESS_CMD(del, redis_long_response);
1062+
PHP_METHOD(Redis, del) {
1063+
REDIS_PROCESS_KW_CMD("DEL", redis_varkey_cmd, redis_long_response);
10591064
}
10601065
/* }}} */
10611066

10621067
/* {{{ proto long Redis::unlink(string $key1, string $key2 [, string $key3...]) }}}
10631068
* {{{ proto long Redis::unlink(array $keys) */
10641069
PHP_METHOD(Redis, unlink)
10651070
{
1066-
REDIS_PROCESS_CMD(unlink, redis_long_response);
1071+
REDIS_PROCESS_KW_CMD("UNLINK", redis_varkey_cmd, redis_long_response);
10671072
}
10681073

10691074
PHP_REDIS_API void redis_set_watch(RedisSock *redis_sock)
@@ -1080,9 +1085,8 @@ PHP_REDIS_API int redis_watch_response(INTERNAL_FUNCTION_PARAMETERS,
10801085

10811086
/* {{{ proto boolean Redis::watch(string key1, string key2...)
10821087
*/
1083-
PHP_METHOD(Redis, watch)
1084-
{
1085-
REDIS_PROCESS_CMD(watch, redis_watch_response);
1088+
PHP_METHOD(Redis, watch) {
1089+
REDIS_PROCESS_KW_CMD("WATCH", redis_varkey_cmd, redis_watch_response);
10861090
}
10871091
/* }}} */
10881092

@@ -1440,7 +1444,7 @@ PHP_METHOD(Redis, sMisMember)
14401444

14411445
/* {{{ proto array Redis::sInter(string key0, ... string keyN) */
14421446
PHP_METHOD(Redis, sInter) {
1443-
REDIS_PROCESS_CMD(sinter, redis_sock_read_multibulk_reply);
1447+
REDIS_PROCESS_KW_CMD("SINTER", redis_varkey_cmd, redis_sock_read_multibulk_reply);
14441448
}
14451449
/* }}} */
14461450

@@ -1450,35 +1454,34 @@ PHP_METHOD(Redis, sintercard) {
14501454

14511455
/* {{{ proto array Redis::sInterStore(string dst, string key0,...string keyN) */
14521456
PHP_METHOD(Redis, sInterStore) {
1453-
REDIS_PROCESS_CMD(sinterstore, redis_long_response);
1457+
REDIS_PROCESS_KW_CMD("SINTERSTORE", redis_varkey_cmd, redis_long_response);
14541458
}
14551459
/* }}} */
14561460

14571461
/* {{{ proto array Redis::sUnion(string key0, ... string keyN) */
14581462
PHP_METHOD(Redis, sUnion) {
1459-
REDIS_PROCESS_CMD(sunion, redis_sock_read_multibulk_reply);
1463+
REDIS_PROCESS_KW_CMD("SUNION", redis_varkey_cmd, redis_sock_read_multibulk_reply);
14601464
}
14611465
/* }}} */
14621466

1463-
/* {{{ proto array Redis::sUnionStore(string dst, string key0, ... keyN) */
1467+
/* {{{ proto array Redis::sUnionStore(array|string $key, string ...$srckeys) */
14641468
PHP_METHOD(Redis, sUnionStore) {
1465-
REDIS_PROCESS_CMD(sunionstore, redis_long_response);
1469+
REDIS_PROCESS_KW_CMD("SUNIONSTORE", redis_varkey_cmd, redis_long_response);
14661470
}
14671471
/* }}} */
14681472

14691473
/* {{{ proto array Redis::sDiff(string key0, ... string keyN) */
14701474
PHP_METHOD(Redis, sDiff) {
1471-
REDIS_PROCESS_CMD(sdiff, redis_sock_read_multibulk_reply);
1475+
REDIS_PROCESS_KW_CMD("SDIFF", redis_varkey_cmd, redis_sock_read_multibulk_reply);
14721476
}
14731477
/* }}} */
14741478

14751479
/* {{{ proto array Redis::sDiffStore(string dst, string key0, ... keyN) */
14761480
PHP_METHOD(Redis, sDiffStore) {
1477-
REDIS_PROCESS_CMD(sdiffstore, redis_long_response);
1481+
REDIS_PROCESS_KW_CMD("SDIFFSTORE", redis_varkey_cmd, redis_long_response);
14781482
}
14791483
/* }}} */
14801484

1481-
14821485
/* {{{ proto array Redis::sort(string key, array options) */
14831486
PHP_METHOD(Redis, sort) {
14841487
REDIS_PROCESS_KW_CMD("SORT", redis_sort_cmd, redis_read_variant_reply);

redis.stub.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,25 @@ public function sismember(string $key, mixed $value): Redis|bool;
567567

568568
public function slaveof(string $host = null, int $port = 6379): bool;
569569

570+
/**
571+
* Update one or more keys last modified metadata.
572+
*
573+
* @see https://redis.io/commands/touch/
574+
*
575+
* @param array|string $key Either the first key or if passed as the only argument
576+
* an array of keys.
577+
* @param string $more_keys One or more keys to send to the command.
578+
*
579+
* @return Redis|int|false This command returns the number of keys that exist and
580+
* had their last modified time reset
581+
*/
582+
public function touch(array|string $key_or_array, string ...$more_keys): Redis|int|false;
583+
570584
/**
571585
* Interact with Redis' slowlog functionality in variousu ways, depending
572586
* on the value of 'operations'.
573587
*
574-
* @see https://https://redis.io/commands/slowlog/
588+
* @see https://redis.io/commands/slowlog/
575589
* @category administration
576590
*
577591
* @param string $operation The operation you wish to perform.  This can

redis_arginfo.h

Lines changed: 8 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: 894a03b9e9db1e8ded0f016a00e7e7150dc26f31 */
2+
* Stub hash: 7c2ec068711e216a4308a2c405c32204edf60d23 */
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")
@@ -797,6 +797,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_slaveof, 0, 0, _IS_B
797797
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "6379")
798798
ZEND_END_ARG_INFO()
799799

800+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_touch, 0, 1, Redis, MAY_BE_LONG|MAY_BE_FALSE)
801+
ZEND_ARG_TYPE_MASK(0, key_or_array, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
802+
ZEND_ARG_VARIADIC_TYPE_INFO(0, more_keys, IS_STRING, 0)
803+
ZEND_END_ARG_INFO()
804+
800805
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_slowlog, 0, 1, IS_MIXED, 0)
801806
ZEND_ARG_TYPE_INFO(0, operation, IS_STRING, 0)
802807
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0")
@@ -1290,6 +1295,7 @@ ZEND_METHOD(Redis, setex);
12901295
ZEND_METHOD(Redis, setnx);
12911296
ZEND_METHOD(Redis, sismember);
12921297
ZEND_METHOD(Redis, slaveof);
1298+
ZEND_METHOD(Redis, touch);
12931299
ZEND_METHOD(Redis, slowlog);
12941300
ZEND_METHOD(Redis, sort);
12951301
ZEND_METHOD(Redis, sort_ro);
@@ -1538,6 +1544,7 @@ static const zend_function_entry class_Redis_methods[] = {
15381544
ZEND_ME(Redis, setnx, arginfo_class_Redis_setnx, ZEND_ACC_PUBLIC)
15391545
ZEND_ME(Redis, sismember, arginfo_class_Redis_sismember, ZEND_ACC_PUBLIC)
15401546
ZEND_ME(Redis, slaveof, arginfo_class_Redis_slaveof, ZEND_ACC_PUBLIC)
1547+
ZEND_ME(Redis, touch, arginfo_class_Redis_touch, ZEND_ACC_PUBLIC)
15411548
ZEND_ME(Redis, slowlog, arginfo_class_Redis_slowlog, ZEND_ACC_PUBLIC)
15421549
ZEND_ME(Redis, sort, arginfo_class_Redis_sort, ZEND_ACC_PUBLIC)
15431550
ZEND_ME(Redis, sort_ro, arginfo_class_Redis_sort_ro, ZEND_ACC_PUBLIC)

redis_cluster.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,18 @@ PHP_METHOD(RedisCluster, getset) {
751751
}
752752
/* }}} */
753753

754-
/* {{{ proto int RedisCluster::exists(string key) */
754+
/* {{{ proto int RedisCluster::exists(string $key, string ...$more_keys) */
755755
PHP_METHOD(RedisCluster, exists) {
756-
CLUSTER_PROCESS_CMD(exists, cluster_long_resp, 1);
756+
CLUSTER_PROCESS_KW_CMD("EXISTS", redis_varkey_cmd, cluster_long_resp, 1);
757757
}
758758
/* }}} */
759759

760+
/* {{{ proto int RedisCluster::exists(string $key, string ...$more_keys) */
761+
PHP_METHOD(RedisCluster, touch) {
762+
CLUSTER_PROCESS_KW_CMD("TOUCH", redis_varkey_cmd, cluster_long_resp, 0);
763+
}
764+
765+
/* }}} */
760766
/* {{{ proto array Redis::keys(string pattern) */
761767
PHP_METHOD(RedisCluster, keys) {
762768
redisCluster *c = GET_CONTEXT();
@@ -1007,19 +1013,19 @@ PHP_METHOD(RedisCluster, srem) {
10071013

10081014
/* {{{ proto array RedisCluster::sunion(string key1, ... keyN) */
10091015
PHP_METHOD(RedisCluster, sunion) {
1010-
CLUSTER_PROCESS_CMD(sunion, cluster_mbulk_resp, 0);
1016+
CLUSTER_PROCESS_KW_CMD("SUNION", redis_varkey_cmd, cluster_mbulk_resp, 0);
10111017
}
10121018
/* }}} */
10131019

10141020
/* {{{ proto long RedisCluster::sunionstore(string dst, string k1, ... kN) */
10151021
PHP_METHOD(RedisCluster, sunionstore) {
1016-
CLUSTER_PROCESS_CMD(sunionstore, cluster_long_resp, 0);
1022+
CLUSTER_PROCESS_KW_CMD("SUNIONSTORE", redis_varkey_cmd, cluster_long_resp, 0);
10171023
}
10181024
/* }}} */
10191025

10201026
/* {{{ ptoto array RedisCluster::sinter(string k1, ... kN) */
10211027
PHP_METHOD(RedisCluster, sinter) {
1022-
CLUSTER_PROCESS_CMD(sinter, cluster_mbulk_resp, 0);
1028+
CLUSTER_PROCESS_KW_CMD("SINTER", redis_varkey_cmd, cluster_mbulk_resp, 0);
10231029
}
10241030

10251031
/* {{{ proto RedisCluster::sintercard(array $keys, int $count = -1) */
@@ -1032,19 +1038,19 @@ PHP_METHOD(RedisCluster, sintercard) {
10321038

10331039
/* {{{ ptoto long RedisCluster::sinterstore(string dst, string k1, ... kN) */
10341040
PHP_METHOD(RedisCluster, sinterstore) {
1035-
CLUSTER_PROCESS_CMD(sinterstore, cluster_long_resp, 0);
1041+
CLUSTER_PROCESS_KW_CMD("SINTERSTORE", redis_varkey_cmd, cluster_long_resp, 0);
10361042
}
10371043
/* }}} */
10381044

10391045
/* {{{ proto array RedisCluster::sdiff(string k1, ... kN) */
10401046
PHP_METHOD(RedisCluster, sdiff) {
1041-
CLUSTER_PROCESS_CMD(sdiff, cluster_mbulk_resp, 1);
1047+
CLUSTER_PROCESS_KW_CMD("SDIFF", redis_varkey_cmd, cluster_mbulk_resp, 1);
10421048
}
10431049
/* }}} */
10441050

10451051
/* {{{ proto long RedisCluster::sdiffstore(string dst, string k1, ... kN) */
10461052
PHP_METHOD(RedisCluster, sdiffstore) {
1047-
CLUSTER_PROCESS_CMD(sdiffstore, cluster_long_resp, 0);
1053+
CLUSTER_PROCESS_KW_CMD("SDIFFSTORE", redis_varkey_cmd, cluster_long_resp, 0);
10481054
}
10491055
/* }}} */
10501056

redis_cluster.stub.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ public function exec(): array|false;
111111

112112
public function exists(mixed $key, mixed ...$other_keys): RedisCluster|int|bool;
113113

114+
/**
115+
* @see Redis::touch()
116+
*/
117+
public function touch(mixed $key, mixed ...$other_keys): RedisCluster|int|bool;
118+
114119
public function expire(string $key, int $timeout, ?string $mode = NULL): RedisCluster|bool;
115120

116121
public function expireat(string $key, int $timestamp, ?string $mode = NULL): RedisCluster|bool;

redis_cluster_arginfo.h

Lines changed: 5 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: b9d2d6314c74dbf1e80662aa867b36c4a3ecfe8d */
2+
* Stub hash: 895f61badfcc6198d72788d80d517144fc1e8daf */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1)
@@ -205,6 +205,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_exists, 0
205205
ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_MIXED, 0)
206206
ZEND_END_ARG_INFO()
207207

208+
#define arginfo_class_RedisCluster_touch arginfo_class_RedisCluster_exists
209+
208210
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_expire, 0, 2, RedisCluster, MAY_BE_BOOL)
209211
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
210212
ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0)
@@ -993,6 +995,7 @@ ZEND_METHOD(RedisCluster, evalsha);
993995
ZEND_METHOD(RedisCluster, evalsha_ro);
994996
ZEND_METHOD(RedisCluster, exec);
995997
ZEND_METHOD(RedisCluster, exists);
998+
ZEND_METHOD(RedisCluster, touch);
996999
ZEND_METHOD(RedisCluster, expire);
9971000
ZEND_METHOD(RedisCluster, expireat);
9981001
ZEND_METHOD(RedisCluster, expiretime);
@@ -1201,6 +1204,7 @@ static const zend_function_entry class_RedisCluster_methods[] = {
12011204
ZEND_ME(RedisCluster, evalsha_ro, arginfo_class_RedisCluster_evalsha_ro, ZEND_ACC_PUBLIC)
12021205
ZEND_ME(RedisCluster, exec, arginfo_class_RedisCluster_exec, ZEND_ACC_PUBLIC)
12031206
ZEND_ME(RedisCluster, exists, arginfo_class_RedisCluster_exists, ZEND_ACC_PUBLIC)
1207+
ZEND_ME(RedisCluster, touch, arginfo_class_RedisCluster_touch, ZEND_ACC_PUBLIC)
12041208
ZEND_ME(RedisCluster, expire, arginfo_class_RedisCluster_expire, ZEND_ACC_PUBLIC)
12051209
ZEND_ME(RedisCluster, expireat, arginfo_class_RedisCluster_expireat, ZEND_ACC_PUBLIC)
12061210
ZEND_ME(RedisCluster, expiretime, arginfo_class_RedisCluster_expiretime, ZEND_ACC_PUBLIC)

redis_cluster_legacy_arginfo.h

Lines changed: 5 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: b9d2d6314c74dbf1e80662aa867b36c4a3ecfe8d */
2+
* Stub hash: 895f61badfcc6198d72788d80d517144fc1e8daf */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
55
ZEND_ARG_INFO(0, name)
@@ -179,6 +179,8 @@ ZEND_END_ARG_INFO()
179179

180180
#define arginfo_class_RedisCluster_exists arginfo_class_RedisCluster_del
181181

182+
#define arginfo_class_RedisCluster_touch arginfo_class_RedisCluster_del
183+
182184
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_expire, 0, 0, 2)
183185
ZEND_ARG_INFO(0, key)
184186
ZEND_ARG_INFO(0, timeout)
@@ -844,6 +846,7 @@ ZEND_METHOD(RedisCluster, evalsha);
844846
ZEND_METHOD(RedisCluster, evalsha_ro);
845847
ZEND_METHOD(RedisCluster, exec);
846848
ZEND_METHOD(RedisCluster, exists);
849+
ZEND_METHOD(RedisCluster, touch);
847850
ZEND_METHOD(RedisCluster, expire);
848851
ZEND_METHOD(RedisCluster, expireat);
849852
ZEND_METHOD(RedisCluster, expiretime);
@@ -1052,6 +1055,7 @@ static const zend_function_entry class_RedisCluster_methods[] = {
10521055
ZEND_ME(RedisCluster, evalsha_ro, arginfo_class_RedisCluster_evalsha_ro, ZEND_ACC_PUBLIC)
10531056
ZEND_ME(RedisCluster, exec, arginfo_class_RedisCluster_exec, ZEND_ACC_PUBLIC)
10541057
ZEND_ME(RedisCluster, exists, arginfo_class_RedisCluster_exists, ZEND_ACC_PUBLIC)
1058+
ZEND_ME(RedisCluster, touch, arginfo_class_RedisCluster_touch, ZEND_ACC_PUBLIC)
10551059
ZEND_ME(RedisCluster, expire, arginfo_class_RedisCluster_expire, ZEND_ACC_PUBLIC)
10561060
ZEND_ME(RedisCluster, expireat, arginfo_class_RedisCluster_expireat, ZEND_ACC_PUBLIC)
10571061
ZEND_ME(RedisCluster, expiretime, arginfo_class_RedisCluster_expiretime, ZEND_ACC_PUBLIC)

redis_commands.c

Lines changed: 5 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4593,84 +4593,13 @@ int redis_migrate_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
45934593
return SUCCESS;
45944594
}
45954595

4596-
/* EXISTS */
4597-
int redis_exists_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4598-
char **cmd, int *cmd_len, short *slot, void **ctx)
4599-
{
4600-
return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
4601-
"EXISTS", sizeof("EXISTS") - 1, 0, 0, cmd, cmd_len, slot);
4602-
}
4603-
4604-
/* DEL */
4605-
int redis_del_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4606-
char **cmd, int *cmd_len, short *slot, void **ctx)
4607-
{
4608-
return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
4609-
"DEL", sizeof("DEL")-1, 1, 0, cmd, cmd_len, slot);
4610-
}
4611-
4612-
/* UNLINK */
4613-
int redis_unlink_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4614-
char **cmd, int *cmd_len, short *slot, void **ctx)
4615-
{
4616-
return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
4617-
"UNLINK", sizeof("UNLINK")-1, 1, 0, cmd, cmd_len, slot);
4618-
}
4619-
4620-
/* WATCH */
4621-
int redis_watch_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4622-
char **cmd, int *cmd_len, short *slot, void **ctx)
4623-
{
4624-
return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
4625-
"WATCH", sizeof("WATCH")-1, 1, 0, cmd, cmd_len, slot);
4626-
}
4627-
4628-
/* SINTER */
4629-
int redis_sinter_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4630-
char **cmd, int *cmd_len, short *slot, void **ctx)
4631-
{
4632-
return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
4633-
"SINTER", sizeof("SINTER")-1, 1, 0, cmd, cmd_len, slot);
4634-
}
4635-
4636-
/* SINTERSTORE */
4637-
int redis_sinterstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4638-
char **cmd, int *cmd_len, short *slot, void **ctx)
4639-
{
4640-
return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
4641-
"SINTERSTORE", sizeof("SINTERSTORE")-1, 1, 0, cmd, cmd_len, slot);
4642-
}
4643-
4644-
/* SUNION */
4645-
int redis_sunion_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4646-
char **cmd, int *cmd_len, short *slot, void **ctx)
4647-
{
4648-
return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
4649-
"SUNION", sizeof("SUNION")-1, 1, 0, cmd, cmd_len, slot);
4650-
}
4651-
4652-
/* SUNIONSTORE */
4653-
int redis_sunionstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4654-
char **cmd, int *cmd_len, short *slot, void **ctx)
4655-
{
4656-
return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
4657-
"SUNIONSTORE", sizeof("SUNIONSTORE")-1, 2, 0, cmd, cmd_len, slot);
4658-
}
4659-
4660-
/* SDIFF */
4661-
int redis_sdiff_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4662-
char **cmd, int *cmd_len, short *slot, void **ctx)
4663-
{
4664-
return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, "SDIFF",
4665-
sizeof("SDIFF")-1, 1, 0, cmd, cmd_len, slot);
4666-
}
4667-
4668-
/* SDIFFSTORE */
4669-
int redis_sdiffstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4670-
char **cmd, int *cmd_len, short *slot, void **ctx)
4596+
/* A generic passthru function for variadic key commands that take one or more
4597+
* keys. This is essentially all of them except ones that STORE data. */
4598+
int redis_varkey_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
4599+
char *kw, char **cmd, int *cmd_len, short *slot, void **ctx)
46714600
{
46724601
return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
4673-
"SDIFFSTORE", sizeof("SDIFFSTORE")-1, 1, 0, cmd, cmd_len, slot);
4602+
kw, strlen(kw), 1, 0, cmd, cmd_len, slot);
46744603
}
46754604

46764605
static int

0 commit comments

Comments
 (0)