-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: M Sazzadul Hoque <[email protected]>
- Loading branch information
1 parent
31513d4
commit 3590438
Showing
8 changed files
with
473 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/redis/clients/jedis/commands/CommandCommands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package redis.clients.jedis.commands; | ||
|
||
import redis.clients.jedis.params.CommandListFilterByParams; | ||
import redis.clients.jedis.resps.CommandDocument; | ||
import redis.clients.jedis.resps.CommandInfo; | ||
import redis.clients.jedis.util.KeyValue; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public interface CommandCommands { | ||
|
||
/** | ||
* The number of total commands in this Redis server | ||
* @return The number of total commands | ||
*/ | ||
long commandCount(); | ||
|
||
/** | ||
* Return documentary information about commands. | ||
* If not specifying commands, the reply includes all the server's commands. | ||
* @param commands specify the names of one or more commands | ||
* @return list of {@link CommandDocument} | ||
*/ | ||
|
||
Map<String, CommandDocument> commandDocs(String... commands); | ||
|
||
/** | ||
* Return list of keys from a full Redis command | ||
* @param command | ||
* @return list of keys | ||
*/ | ||
List<String> commandGetKeys(String... command); | ||
|
||
/** | ||
* Return list of keys from a full Redis command and their usage flags | ||
* @param command | ||
* @return list of {@link KeyValue} | ||
*/ | ||
List<KeyValue<String, List<String>>> commandGetKeysAndFlags(String... command); | ||
|
||
/** | ||
* Return details about multiple Redis commands | ||
* @param commands | ||
* @return list of {@link CommandInfo} | ||
*/ | ||
Map<String, CommandInfo> commandInfo(String... commands); | ||
|
||
/** | ||
* Return a list of the server's command names | ||
* @return commands list | ||
*/ | ||
List<String> commandList(); | ||
|
||
/** | ||
* Return a list of the server's command names filtered by module's name, ACL category or pattern | ||
* @param filterByParams {@link CommandListFilterByParams} | ||
* @return commands list | ||
*/ | ||
List<String> commandListFilterBy(CommandListFilterByParams filterByParams); | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/redis/clients/jedis/params/CommandListFilterByParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package redis.clients.jedis.params; | ||
|
||
import redis.clients.jedis.CommandArguments; | ||
import redis.clients.jedis.exceptions.JedisDataException; | ||
|
||
import static redis.clients.jedis.Protocol.Keyword.FILTERBY; | ||
import static redis.clients.jedis.Protocol.Keyword.MODULE; | ||
import static redis.clients.jedis.Protocol.Keyword.ACLCAT; | ||
import static redis.clients.jedis.Protocol.Keyword.PATTERN; | ||
|
||
public class CommandListFilterByParams implements IParams { | ||
private String moduleName; | ||
private String category; | ||
private String pattern; | ||
|
||
public static CommandListFilterByParams commandListFilterByParams() { | ||
return new CommandListFilterByParams(); | ||
} | ||
|
||
public CommandListFilterByParams filterByModule(String moduleName) { | ||
this.moduleName = moduleName; | ||
return this; | ||
} | ||
|
||
public CommandListFilterByParams filterByAclCat(String category) { | ||
this.category = category; | ||
return this; | ||
} | ||
|
||
public CommandListFilterByParams filterByPattern(String pattern) { | ||
this.pattern = pattern; | ||
return this; | ||
} | ||
|
||
@Override | ||
public void addParams(CommandArguments args) { | ||
args.add(FILTERBY); | ||
|
||
if (moduleName != null && category == null && pattern == null) { | ||
args.add(MODULE); | ||
args.add(moduleName); | ||
} else if (moduleName == null && category != null && pattern == null) { | ||
args.add(ACLCAT); | ||
args.add(category); | ||
} else if (moduleName == null && category == null && pattern != null) { | ||
args.add(PATTERN); | ||
args.add(pattern); | ||
} else { | ||
throw new JedisDataException("Must choose exactly one filter"); | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/redis/clients/jedis/resps/CommandDocument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package redis.clients.jedis.resps; | ||
|
||
import redis.clients.jedis.Builder; | ||
|
||
import static redis.clients.jedis.BuilderFactory.STRING; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CommandDocument { | ||
private final String summary; | ||
private final String since; | ||
private final String group; | ||
private final String complexity; | ||
private final List<String> history; | ||
|
||
public CommandDocument(String summary, String since, String group, String complexity, List<String> history) { | ||
this.summary = summary; | ||
this.since = since; | ||
this.group = group; | ||
this.complexity = complexity; | ||
this.history = history; | ||
} | ||
|
||
public String getSummary() { | ||
return summary; | ||
} | ||
|
||
public String getSince() { | ||
return since; | ||
} | ||
|
||
public String getGroup() { | ||
return group; | ||
} | ||
|
||
public String getComplexity() { | ||
return complexity; | ||
} | ||
|
||
public List<String> getHistory() { | ||
return history; | ||
} | ||
|
||
public static final Builder<CommandDocument> COMMAND_DOCUMENT_BUILDER = new Builder<CommandDocument>() { | ||
@Override | ||
public CommandDocument build(Object data) { | ||
List<Object> commandData = (List<Object>) data; | ||
String summary = STRING.build(commandData.get(1)); | ||
String since = STRING.build(commandData.get(3)); | ||
String group = STRING.build(commandData.get(5)); | ||
String complexity = STRING.build(commandData.get(7)); | ||
List<String> history = null; | ||
if (STRING.build(commandData.get(8)).equals("history")) { | ||
List<List<Object>> rawHistory = (List<List<Object>>) commandData.get(9); | ||
history = new ArrayList<>(rawHistory.size()); | ||
for (List<Object> timePoint : rawHistory) { | ||
history.add(STRING.build(timePoint.get(0)) + ": " + STRING.build(timePoint.get(1))); | ||
} | ||
} | ||
return new CommandDocument(summary, since, group, complexity, history); | ||
} | ||
}; | ||
} |
Oops, something went wrong.