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

Support ROLE command #664

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions src/main/java/redis/clients/jedis/BasicCommands.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package redis.clients.jedis;

import java.util.List;

public interface BasicCommands {

String ping();
Expand Down Expand Up @@ -41,4 +43,6 @@ public interface BasicCommands {
String configResetStat();

Long waitReplicas(int replicas, long timeout);

List<Object> role();
}
49 changes: 29 additions & 20 deletions src/main/java/redis/clients/jedis/BinaryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void incrBy(final byte[] key, final long integer) {
}

public void incrByFloat(final byte[] key, final double value) {
sendCommand(INCRBYFLOAT, key, toByteArray(value));
sendCommand(INCRBYFLOAT, key, toByteArray(value));
}

public void incr(final byte[] key) {
Expand Down Expand Up @@ -320,7 +320,7 @@ public void rpoplpush(final byte[] srckey, final byte[] dstkey) {
public void sadd(final byte[] key, final byte[]... members) {
sendCommand(SADD, joinParameters(key, members));
}

public void smembers(final byte[] key) {
sendCommand(SMEMBERS, key);
}
Expand Down Expand Up @@ -560,10 +560,11 @@ public void punsubscribe() {
public void punsubscribe(final byte[]... patterns) {
sendCommand(PUNSUBSCRIBE, patterns);
}

public void pubsub(final byte[]... args) {
sendCommand(PUBSUB, args);
sendCommand(PUBSUB, args);
}

public void zcount(final byte[] key, final double min, final double max) {

byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf"
Expand Down Expand Up @@ -929,15 +930,16 @@ public void setbit(byte[] key, long offset, boolean value) {
public void getbit(byte[] key, long offset) {
sendCommand(GETBIT, key, toByteArray(offset));
}

public void bitpos(final byte[] key, final boolean value, final BitPosParams params) {

public void bitpos(final byte[] key, final boolean value,
final BitPosParams params) {
final List<byte[]> args = new ArrayList<byte[]>();
args.add(key);
args.add(toByteArray(value));
args.addAll(params.getParams());
sendCommand(BITPOS, args.toArray(new byte[args.size()][]));
}

public void setrange(byte[] key, long offset, byte[] value) {
sendCommand(SETRANGE, key, toByteArray(offset), value);
}
Expand Down Expand Up @@ -1037,6 +1039,10 @@ public void slowlogLen() {
sendCommand(SLOWLOG, LEN.raw);
}

public void role() {
sendCommand(ROLE);
}

public void objectRefcount(byte[] key) {
sendCommand(OBJECT, REFCOUNT.raw, key);
}
Expand Down Expand Up @@ -1191,7 +1197,7 @@ public void hscan(final byte[] key, int cursor, final ScanParams params) {
args.addAll(params.getParams());
sendCommand(HSCAN, args.toArray(new byte[args.size()][]));
}

@Deprecated
/**
* This method is deprecated due to bug (scan cursor should be unsigned long)
Expand All @@ -1205,7 +1211,7 @@ public void sscan(final byte[] key, int cursor, final ScanParams params) {
args.addAll(params.getParams());
sendCommand(SSCAN, args.toArray(new byte[args.size()][]));
}

@Deprecated
/**
* This method is deprecated due to bug (scan cursor should be unsigned long)
Expand All @@ -1219,31 +1225,34 @@ public void zscan(final byte[] key, int cursor, final ScanParams params) {
args.addAll(params.getParams());
sendCommand(ZSCAN, args.toArray(new byte[args.size()][]));
}

public void scan(final byte[] cursor, final ScanParams params) {
final List<byte[]> args = new ArrayList<byte[]>();
args.add(cursor);
args.addAll(params.getParams());
sendCommand(SCAN, args.toArray(new byte[args.size()][]));
}

public void hscan(final byte[] key, final byte[] cursor, final ScanParams params) {
public void hscan(final byte[] key, final byte[] cursor,
final ScanParams params) {
final List<byte[]> args = new ArrayList<byte[]>();
args.add(key);
args.add(cursor);
args.addAll(params.getParams());
sendCommand(HSCAN, args.toArray(new byte[args.size()][]));
}

public void sscan(final byte[] key, final byte[] cursor, final ScanParams params) {
public void sscan(final byte[] key, final byte[] cursor,
final ScanParams params) {
final List<byte[]> args = new ArrayList<byte[]>();
args.add(key);
args.add(cursor);
args.addAll(params.getParams());
sendCommand(SSCAN, args.toArray(new byte[args.size()][]));
}

public void zscan(final byte[] key, final byte[] cursor, final ScanParams params) {
public void zscan(final byte[] key, final byte[] cursor,
final ScanParams params) {
final List<byte[]> args = new ArrayList<byte[]>();
args.add(key);
args.add(cursor);
Expand All @@ -1262,20 +1271,20 @@ public void cluster(final byte[]... args) {
public void asking() {
sendCommand(Command.ASKING);
}

public void pfadd(final byte[] key, final byte[]... elements) {
sendCommand(PFADD, joinParameters(key, elements));
sendCommand(PFADD, joinParameters(key, elements));
}

public void pfcount(final byte[] key) {
sendCommand(PFCOUNT, key);
sendCommand(PFCOUNT, key);
}

public void pfcount(final byte[]...keys) {
sendCommand(PFCOUNT, keys);
public void pfcount(final byte[]... keys) {
sendCommand(PFCOUNT, keys);
}

public void pfmerge(final byte[] destkey, final byte[]... sourcekeys) {
sendCommand(PFMERGE, joinParameters(destkey, sourcekeys));
sendCommand(PFMERGE, joinParameters(destkey, sourcekeys));
}
}
7 changes: 7 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -3478,6 +3478,13 @@ public Long waitReplicas(int replicas, long timeout) {
return client.getIntegerReply();
}

@Override
public List<Object> role() {
checkIsInMulti();
client.role();
return client.getObjectMultiBulkReply();
}

@Override
public Long pfadd(final byte[] key, final byte[]... elements) {
checkIsInMulti();
Expand Down
Loading