Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f05e044
Commands [..] commands
Feb 22, 2022
4be5a48
Update CommandInfo.java
Avital-Fine Feb 22, 2022
3c7e7d6
Update KeyedFlags.java
Avital-Fine Feb 22, 2022
9ea6e52
Update CommandDocs.java
Avital-Fine Feb 22, 2022
b31c554
indentation
Feb 22, 2022
67ef2ff
Merge branch 'master' into COMMAND
Avital-Fine Feb 23, 2022
b0123cf
Merge branch 'master' into COMMAND
Avital-Fine Feb 23, 2022
0e800a0
fix function name
Feb 24, 2022
6d03e04
Merge remote-tracking branch 'upstream/COMMAND' into COMMAND
Feb 24, 2022
9621426
Merge branch 'master' into COMMAND
Avital-Fine Feb 24, 2022
37bd8e5
Merge branch 'master' into COMMAND
Avital-Fine Mar 1, 2022
25e1a21
Merge branch 'master' into COMMAND
Avital-Fine Mar 4, 2022
b05cd5c
Update src/main/java/redis/clients/jedis/Protocol.java
Avital-Fine Mar 6, 2022
5fb4bf4
Update src/main/java/redis/clients/jedis/Jedis.java
Avital-Fine Mar 6, 2022
06eace6
fix
Mar 6, 2022
62d7f71
add CommandListFilterByParams
Mar 6, 2022
d790655
Update src/main/java/redis/clients/jedis/BuilderFactory.java
Avital-Fine Mar 6, 2022
d44b4f7
resolve conflicts
Mar 6, 2022
11ba5fe
fix bug
Mar 6, 2022
19403d6
Update src/main/java/redis/clients/jedis/params/CommandListFilterByPa…
Avital-Fine Mar 7, 2022
2ad21d6
Merge branch 'master' into COMMAND
Avital-Fine Mar 7, 2022
4d10d8d
clean builders
Mar 8, 2022
ec24009
Update src/main/java/redis/clients/jedis/CommandObjects.java
Avital-Fine Mar 8, 2022
b2c03f1
Update src/main/java/redis/clients/jedis/UnifiedJedis.java
Avital-Fine Mar 8, 2022
e16e557
restore commands in Jedis.java
Mar 8, 2022
13768ea
format
sazzad16 Mar 8, 2022
1e4226a
implement commands in jedis
Mar 8, 2022
87e356a
test exception
Mar 8, 2022
0af1881
test exception
Mar 8, 2022
a750c34
test exception
Mar 8, 2022
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
88 changes: 88 additions & 0 deletions src/main/java/redis/clients/jedis/BuilderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,94 @@ public String toString() {
}
};

public static final Builder<List<CommandDocs>> COMMAND_DOCS_RESPONSE = new Builder<List<CommandDocs>>() {
@Override
public List<CommandDocs> build(Object data) {
if (data == null) {
return null;
}

List<Object> rawList = (List<Object>) data;
List<CommandDocs> list = new ArrayList<>(rawList.size());

for (int i = 0; i < rawList.size();) {
String name = STRING.build(rawList.get(i++));
List<Object> commandData = (List<Object>) rawList.get(i++);
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)));
}
}

list.add(new CommandDocs(name, summary, since, group, complexity, history));
}

return list;
}
};

public static final Builder<List<KeyedFlags>> KEYS_AND_FLAGS = new Builder<List<KeyedFlags>>() {
@Override
public List<KeyedFlags> build(Object data) {
if (data == null) {
return null;
}

List<Object> rawList = (List<Object>) data;
List<KeyedFlags> list = new ArrayList<>(rawList.size());

for (Object rawKeyInfo : rawList) {
List<Object> keyInfo = (List<Object>) rawKeyInfo;
String name = STRING.build(keyInfo.get(0));
List<String> flags = STRING_LIST.build(keyInfo.get(1));
list.add(new KeyedFlags(name, flags));
}

return list;
}
};

public static final Builder<List<CommandInfo>> COMMAND_INFO_RESPONSE = new Builder<List<CommandInfo>>() {
@Override
public List<CommandInfo> build(Object data) {
if (data == null) {
return null;
}

List<Object> rawList = (List<Object>) data;
List<CommandInfo> list = new ArrayList<>(rawList.size());

for (Object rawCommandInfo : rawList) {
if (rawCommandInfo == null) {
list.add(null);
break;
}

List<Object> commandInfo = (List<Object>) rawCommandInfo;
String name = STRING.build(commandInfo.get(0));
long arity = LONG.build(commandInfo.get(1));
List<String> flags = STRING_LIST.build(commandInfo.get(2));
long firstKey = LONG.build(commandInfo.get(3));
long lastKey = LONG.build(commandInfo.get(4));
long step = LONG.build(commandInfo.get(5));
List<String> aclCategories = STRING_LIST.build(commandInfo.get(6));
List<String> tips = STRING_LIST.build(commandInfo.get(7));
List<String> subcommands = STRING_LIST.build(commandInfo.get(9));

list.add(new CommandInfo(name, arity, flags, firstKey, lastKey, step, aclCategories, tips, subcommands));
}

return list;
}
};

public static final Builder<List<Module>> MODULE_LIST = new Builder<List<Module>>() {
@Override
public List<Module> build(Object data) {
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -3032,6 +3032,45 @@ public final CommandObject<Long> publish(byte[] channel, byte[] message) {
}
// Miscellaneous commands

public final CommandObject<Long> commandCount() {
return new CommandObject<>(commandArguments(COMMAND).add(COUNT), BuilderFactory.LONG);
}

public final CommandObject<List<CommandDocs>> commandDocs(String... commands) {
return new CommandObject<>(commandArguments(COMMAND).add(DOCS).addObjects((Object[]) commands), BuilderFactory.COMMAND_DOCS_RESPONSE);
}

public final CommandObject<List<String>> commandGetKeys(String... command) {
return new CommandObject<>(commandArguments(COMMAND).add(GETKEYS).addObjects((Object[]) command), BuilderFactory.STRING_LIST);
}

public final CommandObject<List<KeyedFlags>> commandGetKeysAndFlags(String... command) {
return new CommandObject<>(commandArguments(COMMAND).add(GETKEYSANDFLAGS).addObjects((Object[]) command), BuilderFactory.KEYS_AND_FLAGS);
}

public final CommandObject<List<CommandInfo>> commandInfo(String... commands) {
return new CommandObject<>(commandArguments(COMMAND).add(Keyword.INFO).addObjects((Object[]) commands), BuilderFactory.COMMAND_INFO_RESPONSE);
}

public final CommandObject<List<String>> commandList() {
return new CommandObject<>(commandArguments(COMMAND).add(LIST), BuilderFactory.STRING_LIST);
}

public final CommandObject<List<String>> commandListFilterByModule(String moduleName) {
return new CommandObject<>(commandArguments(COMMAND).add(LIST).add(FILTERBY).add(MODULE).add(moduleName),
BuilderFactory.STRING_LIST);
}

public final CommandObject<List<String>> commandListFilterByAclcat(String moduleName) {
return new CommandObject<>(commandArguments(COMMAND).add(LIST).add(FILTERBY).add(ACLCAT).add(moduleName),
BuilderFactory.STRING_LIST);
}

public final CommandObject<List<String>> commandListFilterByPattern(String pattern) {
return new CommandObject<>(commandArguments(COMMAND).add(LIST).add(FILTERBY).add(PATTERN).add(pattern),
BuilderFactory.STRING_LIST);
}

// RediSearch commands
public CommandObject<String> ftCreate(String indexName, IndexOptions indexOptions, Schema schema) {
CommandArguments args = commandArguments(SearchCommand.CREATE).add(indexName)
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -8042,6 +8042,61 @@ 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 List<CommandDocs> commandDocs(String... commands) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.commandDocs(commands));
}

@Override
public List<String> commandGetKeys(String... command) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.commandGetKeys(command));
}

@Override
public List<KeyedFlags> commandGetKeysAndFlags(String... command) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.commandGetKeysAndFlags(command));
}

@Override
public List<CommandInfo> commandInfo(String... commands) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.commandInfo(commands));
}

@Override
public List<String> commandList() {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.commandList());
}

@Override
public List<String> commandListFilterByModule(String moduleName) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.commandListFilterByModule(moduleName));
}

@Override
public List<String> commandListFilterByAclcat(String category) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.commandListFilterByAclcat(category));
}

@Override
public List<String> commandListFilterByPattern(String pattern) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.commandListFilterByPattern(pattern));
}

@Override
public String sentinelMyId() {
connection.sendCommand(SENTINEL, MYID);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/redis/clients/jedis/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ public static enum Command implements ProtocolCommand {
GEORADIUSBYMEMBER, GEORADIUSBYMEMBER_RO, BITFIELD, TOUCH, SWAPDB, MEMORY, BZPOPMIN, BZPOPMAX,
XADD, XLEN, XDEL, XTRIM, XRANGE, XREVRANGE, XREAD, XACK, XGROUP, XREADGROUP, XPENDING, XCLAIM,
XAUTOCLAIM, XINFO, BITFIELD_RO, ROLE, FAILOVER, GEOSEARCH, GEOSEARCHSTORE, EVAL_RO, EVALSHA_RO,
LOLWUT, EXPIRETIME, PEXPIRETIME, FUNCTION, FCALL, FCALL_RO, LMPOP, BLMPOP, ZMPOP, BZMPOP,
@Deprecated STRALGO;
LOLWUT, EXPIRETIME, PEXPIRETIME, FUNCTION, FCALL, FCALL_RO, LMPOP, BLMPOP, ZMPOP, BZMPOP,COMMAND,
DOCS, GETKEYS, GETKEYSANDFLAGS, @Deprecated STRALGO;

private final byte[] raw;

Expand All @@ -262,8 +262,8 @@ public static enum Keyword implements Rawable {
TIMEOUT, ABORT, NX, XX, EX, PX, EXAT, PXAT, CH, WITHCOORD, WITHDIST, WITHHASH, STOREDIST, COPY,
KEEPTTL, AUTH, AUTH2, INFO, CHANNELS, NUMPAT, NUMSUB, FULL, NOW, VERSION, KEYS, IDX, SCHEDULE,
ANY, FROMMEMBER, FROMLONLAT, BYRADIUS, BYBOX, BYLEX, BYSCORE, REV, MINMATCHLEN, WITHMATCHLEN,
PURGE, STATS, CREATECONSUMER, DELETE, LIBRARYNAME, WITHCODE, DESCRIPTION,
@Deprecated LCS, @Deprecated STRINGS;
PURGE, STATS, CREATECONSUMER, DELETE, LIBRARYNAME, WITHCODE, DESCRIPTION, FILTERBY, ACLCAT,
PATTERN, @Deprecated LCS, @Deprecated STRINGS;

private final byte[] raw;

Expand Down
45 changes: 45 additions & 0 deletions src/main/java/redis/clients/jedis/UnifiedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,51 @@ public Set<String> keys(String pattern) {
return executeCommand(commandObjects.keys(pattern));
}

@Override
public long commandCount() {
return executeCommand(commandObjects.commandCount());
}

@Override
public List<CommandDocs> commandDocs(String... commands) {
return executeCommand(commandObjects.commandDocs(commands));
}

@Override
public List<String> commandGetKeys(String... command) {
return executeCommand(commandObjects.commandGetKeys(command));
}

@Override
public List<KeyedFlags> commandGetKeysAndFlags(String... command) {
return executeCommand(commandObjects.commandGetKeysAndFlags(command));
}

@Override
public List<CommandInfo> commandInfo(String... commands) {
return executeCommand(commandObjects.commandInfo(commands));
}

@Override
public List<String> commandList() {
return executeCommand(commandObjects.commandList());
}

@Override
public List<String> commandListFilterByModule(String moduleName) {
return executeCommand(commandObjects.commandListFilterByModule(moduleName));
}

@Override
public List<String> commandListFilterByAclcat(String category) {
return executeCommand(commandObjects.commandListFilterByAclcat(category));
}

@Override
public List<String> commandListFilterByPattern(String pattern) {
return executeCommand(commandObjects.commandListFilterByPattern(pattern));
}

@Override
public ScanResult<String> scan(String cursor) {
return executeCommand(commandObjects.scan(cursor));
Expand Down
73 changes: 73 additions & 0 deletions src/main/java/redis/clients/jedis/commands/CommandCommands.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package redis.clients.jedis.commands;

import redis.clients.jedis.resps.CommandDocs;
import redis.clients.jedis.resps.CommandInfo;
import redis.clients.jedis.resps.KeyedFlags;

import java.util.List;

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 CommandDocs}
*/

List<CommandDocs> 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 KeyedFlags}
*/
List<KeyedFlags> commandGetKeysAndFlags(String... command);

/**
* Return details about multiple Redis commands
* @param commands
* @return list of {@link CommandInfo}
*/
List<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 filter by module's name
* @param moduleName
* @return commands list
*/
List<String> commandListFilterByModule(String moduleName);

/**
* Return a list of the server's command names filter by ACL category
* @param category
* @return commands list
*/
List<String> commandListFilterByAclcat(String category);

/**
* Return a list of the server's command names filter by glob-like pattern
* @param pattern
* @return commands list
*/
List<String> commandListFilterByPattern(String pattern);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public interface JedisCommands extends KeyCommands, StringCommands, ListCommands, HashCommands,
SetCommands, SortedSetCommands, GeoCommands, HyperLogLogCommands, StreamCommands,
ScriptingKeyCommands, FunctionCommands {
ScriptingKeyCommands, FunctionCommands, CommandCommands {
}
Loading