+ if (argc < 4)
+ return RedisModule_WrongArity(ctx);
+
+ DelParams delParams = {
+ .keys = argv + 1,
+ .length = argc - 3
+ };
+ PubParams pubParams = {
+ .channel_msg_pairs = argv + 1 + delParams.length,
+ .length = 2
+ };
+
+ return delPubStringCommon(ctx, &delParams, &pubParams);
+}
+
+int DelMPub_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
+{
+ if (argc < 6)
+ return RedisModule_WrongArity(ctx);
+
+ long long delCount, pubPairsCount;
+ RedisModule_StringToLongLong(argv[1], &delCount);
+ RedisModule_StringToLongLong(argv[2], &pubPairsCount);
+ if (delCount < 1 || pubPairsCount < 1)
+ return RedisModule_ReplyWithError(ctx, "ERR DEL_COUNT and PUB_PAIR_COUNT must be greater than zero");
+
+ long long delLen, pubLen;
+ delLen = delCount;
+ pubLen = 2*pubPairsCount;
+ if (delLen + pubLen + 3 != argc)
+ return RedisModule_ReplyWithError(ctx, "ERR DEL_COUNT or PUB_PAIR_COUNT do not match the total pair count");
+
+ DelParams delParams = {
+ .keys = argv + 3,
+ .length = delLen
+ };
+ PubParams pubParams = {
+ .channel_msg_pairs = argv + 3 + delParams.length,
+ .length = pubLen
+ };
+
+ return delPubStringCommon(ctx, &delParams, &pubParams);
+}
+
+int delIENEPubStringCommon(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int flag)
+{
+ if (argc < 5 || (argc % 2) == 0)
+ return RedisModule_WrongArity(ctx);
+
+ DelParams delParams = {
+ .keys = argv + 1,
+ .length = 1
+ };
+ PubParams pubParams = {
+ .channel_msg_pairs = argv + 3,
+ .length = argc - 3
+ };
+ RedisModuleString *key = argv[1];
+ RedisModuleString *oldvalstr = argv[2];
+
+ int type = getKeyType(ctx, key);
+ if (type == REDISMODULE_KEYTYPE_EMPTY) {
+ return RedisModule_ReplyWithLongLong(ctx, 0);
+ } else if (type != REDISMODULE_KEYTYPE_STRING) {
+ return RedisModule_ReplyWithError(ctx, REDISMODULE_ERRORMSG_WRONGTYPE);
+ }
+
+ RedisModuleCallReply *reply = RedisModule_Call(ctx, "GET", "s", key);
+ ASSERT_NOERROR(reply)
+ bool is_equal = replyContentsEqualString(reply, oldvalstr);
+ RedisModule_FreeCallReply(reply);
+ if ((flag == OBJ_OP_IE && !is_equal) ||
+ (flag == OBJ_OP_NE && is_equal)) {
+ return RedisModule_ReplyWithLongLong(ctx, 0);
+ }
+
+ return delPubStringCommon(ctx, &delParams, &pubParams);