Skip to content

Commit 1e4226a

Browse files
author
Avital-Fine
committed
implement commands in jedis
1 parent 13768ea commit 1e4226a

File tree

3 files changed

+18
-30
lines changed

3 files changed

+18
-30
lines changed

src/main/java/redis/clients/jedis/CommandObjects.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -632,29 +632,6 @@ public final CommandObject<Long> bitop(BitOP op, byte[] destKey, byte[]... srcKe
632632
return new CommandObject<>(commandArguments(BITOP).add(op).key(destKey).keys((Object[]) srcKeys), BuilderFactory.LONG);
633633
}
634634

635-
public final CommandObject<Long> commandCount() {
636-
return new CommandObject<>(commandArguments(COMMAND).add(COUNT), BuilderFactory.LONG);
637-
}
638-
public final CommandObject<Map<String, CommandDocument>> commandDocs(String... commands) {
639-
return new CommandObject<>(commandArguments(COMMAND).add(DOCS).addObjects((Object[]) commands), BuilderFactory.COMMAND_DOCS_RESPONSE);
640-
}
641-
public final CommandObject<List<String>> commandGetKeys(String... command) {
642-
return new CommandObject<>(commandArguments(COMMAND).add(GETKEYS).addObjects((Object[]) command), BuilderFactory.STRING_LIST);
643-
}
644-
public final CommandObject<List<KeyValue<String, List<String>>>> commandGetKeysAndFlags(String... command) {
645-
return new CommandObject<>(commandArguments(COMMAND).add(GETKEYSANDFLAGS).addObjects((Object[]) command), BuilderFactory.KEYED_STRING_LIST_LIST);
646-
}
647-
public final CommandObject<Map<String, CommandInfo>> commandInfo(String... commands) {
648-
return new CommandObject<>(commandArguments(COMMAND).add(Keyword.INFO).addObjects((Object[]) commands), BuilderFactory.COMMAND_INFO_RESPONSE);
649-
}
650-
public final CommandObject<List<String>> commandList() {
651-
return new CommandObject<>(commandArguments(COMMAND).add(LIST), BuilderFactory.STRING_LIST);
652-
}
653-
public final CommandObject<List<String>> commandListFilterBy(CommandListFilterByParams filterByParams) {
654-
return new CommandObject<>(commandArguments(COMMAND).add(LIST).addParams(filterByParams),
655-
BuilderFactory.STRING_LIST);
656-
}
657-
658635
/**
659636
* @deprecated STRALGO LCS command will be removed from Redis 7.
660637
* LCS can be used instead of this method.

src/main/java/redis/clients/jedis/Jedis.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8044,37 +8044,45 @@ public long bitop(final BitOP op, final String destKey, final String... srcKeys)
80448044

80458045
public long commandCount() {
80468046
checkIsInMultiOrPipeline();
8047-
return connection.executeCommand(commandObjects.commandCount());
8047+
connection.sendCommand(COMMAND, COUNT);
8048+
return connection.getIntegerReply();
80488049
}
80498050

80508051
public Map<String, CommandDocument> commandDocs(String... commands) {
80518052
checkIsInMultiOrPipeline();
8052-
return connection.executeCommand(commandObjects.commandDocs(commands));
8053+
connection.sendCommand(COMMAND, joinParameters(DOCS.name(), commands));
8054+
return BuilderFactory.COMMAND_DOCS_RESPONSE.build(connection.getOne());
80538055
}
80548056

80558057
public List<String> commandGetKeys(String... command) {
80568058
checkIsInMultiOrPipeline();
8057-
return connection.executeCommand(commandObjects.commandGetKeys(command));
8059+
connection.sendCommand(COMMAND, joinParameters(GETKEYS.name(), command));
8060+
return BuilderFactory.STRING_LIST.build(connection.getOne());
80588061
}
80598062

80608063
public List<KeyValue<String, List<String>>> commandGetKeysAndFlags(String... command) {
80618064
checkIsInMultiOrPipeline();
8062-
return connection.executeCommand(commandObjects.commandGetKeysAndFlags(command));
8065+
connection.sendCommand(COMMAND, joinParameters(GETKEYSANDFLAGS.name(), command));
8066+
return BuilderFactory.KEYED_STRING_LIST_LIST.build(connection.getOne());
80638067
}
80648068

80658069
public Map<String, CommandInfo> commandInfo(String... commands) {
80668070
checkIsInMultiOrPipeline();
8067-
return connection.executeCommand(commandObjects.commandInfo(commands));
8071+
connection.sendCommand(COMMAND, joinParameters(Keyword.INFO.name(), commands));
8072+
return BuilderFactory.COMMAND_INFO_RESPONSE.build(connection.getOne());
80688073
}
80698074

80708075
public List<String> commandList() {
80718076
checkIsInMultiOrPipeline();
8072-
return connection.executeCommand(commandObjects.commandList());
8077+
connection.sendCommand(COMMAND, LIST);
8078+
return BuilderFactory.STRING_LIST.build(connection.getOne());
80738079
}
80748080

80758081
public List<String> commandListFilterBy(CommandListFilterByParams filterByParams) {
80768082
checkIsInMultiOrPipeline();
8077-
return connection.executeCommand(commandObjects.commandListFilterBy(filterByParams));
8083+
CommandArguments args = new CommandArguments(COMMAND).add(LIST).addParams(filterByParams);
8084+
connection.sendCommand(args);
8085+
return BuilderFactory.STRING_LIST.build(connection.getOne());
80788086
}
80798087

80808088
@Override

src/main/java/redis/clients/jedis/params/CommandListFilterByParams.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package redis.clients.jedis.params;
22

33
import redis.clients.jedis.CommandArguments;
4+
import redis.clients.jedis.exceptions.JedisDataException;
45

56
import static redis.clients.jedis.Protocol.Keyword.FILTERBY;
67
import static redis.clients.jedis.Protocol.Keyword.MODULE;
@@ -44,6 +45,8 @@ public void addParams(CommandArguments args) {
4445
} else if (moduleName == null && category == null && pattern != null) {
4546
args.add(PATTERN);
4647
args.add(pattern);
48+
} else {
49+
throw new JedisDataException("Must choose exactly one filter");
4750
}
4851
}
4952
}

0 commit comments

Comments
 (0)