Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[code cleanup] Jedis client to implement CommandCommands interface #4077

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public class Jedis implements ServerCommands, DatabaseCommands, JedisCommands, JedisBinaryCommands,
ControlCommands, ControlBinaryCommands, ClusterCommands, ModuleCommands, GenericControlCommands,
SentinelCommands, Closeable {
SentinelCommands, CommandCommands, Closeable {

protected final Connection connection;
private final CommandObjects commandObjects = new CommandObjects();
Expand Down Expand Up @@ -8223,48 +8223,56 @@ public long bitop(final BitOP op, final String destKey, final String... srcKeys)
return connection.executeCommand(commandObjects.bitop(op, destKey, srcKeys));
}

@Override
public long commandCount() {
checkIsInMultiOrPipeline();
connection.sendCommand(COMMAND, COUNT);
return connection.getIntegerReply();
}

@Override
public Map<String, CommandDocument> commandDocs(String... commands) {
checkIsInMultiOrPipeline();
connection.sendCommand(COMMAND, joinParameters(DOCS.name(), commands));
return BuilderFactory.COMMAND_DOCS_RESPONSE.build(connection.getOne());
}

@Override
public List<String> commandGetKeys(String... command) {
checkIsInMultiOrPipeline();
connection.sendCommand(COMMAND, joinParameters(GETKEYS.name(), command));
return BuilderFactory.STRING_LIST.build(connection.getOne());
}

@Override
public List<KeyValue<String, List<String>>> commandGetKeysAndFlags(String... command) {
checkIsInMultiOrPipeline();
connection.sendCommand(COMMAND, joinParameters(GETKEYSANDFLAGS.name(), command));
return BuilderFactory.KEYED_STRING_LIST_LIST.build(connection.getOne());
}

@Override
public Map<String, CommandInfo> commandInfo(String... commands) {
checkIsInMultiOrPipeline();
connection.sendCommand(COMMAND, joinParameters(Keyword.INFO.name(), commands));
return CommandInfo.COMMAND_INFO_RESPONSE.build(connection.getOne());
}

@Override
public Map<String, CommandInfo> command() {
checkIsInMultiOrPipeline();
connection.sendCommand(COMMAND);
return CommandInfo.COMMAND_INFO_RESPONSE.build(connection.getOne());
}

@Override
public List<String> commandList() {
checkIsInMultiOrPipeline();
connection.sendCommand(COMMAND, LIST);
return BuilderFactory.STRING_LIST.build(connection.getOne());
}

@Override
public List<String> commandListFilterBy(CommandListFilterByParams filterByParams) {
checkIsInMultiOrPipeline();
CommandArguments args = new CommandArguments(COMMAND).add(LIST).addParams(filterByParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public interface CommandCommands {
*/
Map<String, CommandInfo> commandInfo(String... commands);

/**
* Return an array with details about every Redis command.
* @return list of {@link CommandInfo}
*/
Map<String, CommandInfo> command();

/**
* Return a list of the server's command names
* @return commands list
Expand Down
Loading