-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Support COMMAND [...] commands #2922
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
f05e044
Commands [..] commands
4be5a48
Update CommandInfo.java
Avital-Fine 3c7e7d6
Update KeyedFlags.java
Avital-Fine 9ea6e52
Update CommandDocs.java
Avital-Fine b31c554
indentation
67ef2ff
Merge branch 'master' into COMMAND
Avital-Fine b0123cf
Merge branch 'master' into COMMAND
Avital-Fine 0e800a0
fix function name
6d03e04
Merge remote-tracking branch 'upstream/COMMAND' into COMMAND
9621426
Merge branch 'master' into COMMAND
Avital-Fine 37bd8e5
Merge branch 'master' into COMMAND
Avital-Fine 25e1a21
Merge branch 'master' into COMMAND
Avital-Fine b05cd5c
Update src/main/java/redis/clients/jedis/Protocol.java
Avital-Fine 5fb4bf4
Update src/main/java/redis/clients/jedis/Jedis.java
Avital-Fine 06eace6
fix
62d7f71
add CommandListFilterByParams
d790655
Update src/main/java/redis/clients/jedis/BuilderFactory.java
Avital-Fine d44b4f7
resolve conflicts
11ba5fe
fix bug
19403d6
Update src/main/java/redis/clients/jedis/params/CommandListFilterByPa…
Avital-Fine 2ad21d6
Merge branch 'master' into COMMAND
Avital-Fine 4d10d8d
clean builders
ec24009
Update src/main/java/redis/clients/jedis/CommandObjects.java
Avital-Fine b2c03f1
Update src/main/java/redis/clients/jedis/UnifiedJedis.java
Avital-Fine e16e557
restore commands in Jedis.java
13768ea
format
sazzad16 1e4226a
implement commands in jedis
87e356a
test exception
0af1881
test exception
a750c34
test exception
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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); | ||
Avital-Fine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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"); | ||
| } | ||
Avital-Fine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
64 changes: 64 additions & 0 deletions
64
src/main/java/redis/clients/jedis/resps/CommandDocument.java
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.