Skip to content

Commit eb6cc47

Browse files
ggivosazzad16
andauthored
Implement command (no arg) (#4026)
* Implement command (no arg) https://redis.io/docs/latest/commands/command/ Adding it for completeness and as alternative to COMMAND INFO for Redis server prior 7.0.0. COMMAND (no args) is available with Redis 2.x COMMAND INFO is available since REDIS version 7.0.0 Relates to: #2922 Support COMMAND commands (#2922) commit : 3590438 Closes #793 * Update ControlCommandsTest.java --------- Co-authored-by: M Sazzadul Hoque <[email protected]>
1 parent fcdc0d5 commit eb6cc47

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -8253,6 +8253,12 @@ public Map<String, CommandInfo> commandInfo(String... commands) {
82538253
return CommandInfo.COMMAND_INFO_RESPONSE.build(connection.getOne());
82548254
}
82558255

8256+
public Map<String, CommandInfo> command() {
8257+
checkIsInMultiOrPipeline();
8258+
connection.sendCommand(COMMAND);
8259+
return CommandInfo.COMMAND_INFO_RESPONSE.build(connection.getOne());
8260+
}
8261+
82568262
public List<String> commandList() {
82578263
checkIsInMultiOrPipeline();
82588264
connection.sendCommand(COMMAND, LIST);

src/test/java/redis/clients/jedis/commands/jedis/ControlCommandsTest.java

+22
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,28 @@ public void commandGetKeys() {
501501
assertEquals(2, keySandFlags.get(0).getValue().size());
502502
}
503503

504+
505+
@Test
506+
public void commandNoArgs() {
507+
Map<String, CommandInfo> infos = jedis.command();
508+
509+
assertThat(infos.size(), greaterThan(0));
510+
511+
CommandInfo getInfo = infos.get("get");
512+
assertEquals(2, getInfo.getArity());
513+
assertEquals(2, getInfo.getFlags().size());
514+
assertEquals(1, getInfo.getFirstKey());
515+
assertEquals(1, getInfo.getLastKey());
516+
assertEquals(1, getInfo.getStep());
517+
518+
assertNull(infos.get("foo")); // non-existing command
519+
520+
CommandInfo setInfo = infos.get("set");
521+
assertEquals(3, setInfo.getAclCategories().size());
522+
assertEquals(0, setInfo.getTips().size());
523+
assertEquals(0, setInfo.getSubcommands().size());
524+
}
525+
504526
@Test
505527
public void commandInfo() {
506528
Map<String, CommandInfo> infos = jedis.commandInfo("GET", "foo", "SET");

0 commit comments

Comments
 (0)