Skip to content

Commit

Permalink
handle resp3 messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sankarcheppali committed Aug 26, 2023
1 parent 88ae7e2 commit e7de9fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/java/redis/clients/jedis/JedisPubSubBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

public abstract class JedisPubSubBase<T> {

private static final byte[] INVALIDATE_CHANNEL = SafeEncoder.encode("__redis__:invalidate");
private int subscribedChannels = 0;
private volatile Connection client;

Expand Down Expand Up @@ -163,6 +164,14 @@ private void process() {
final byte[] bpattern = (byte[]) listReply.get(1);
final T enpattern = (bpattern == null) ? null : encode(bpattern);
onPong(enpattern);
} else if (Arrays.equals(INVALIDATE.getRaw(), resp)) {
final T enchannel = encode(INVALIDATE_CHANNEL);
final List<byte[]> bkeys = (List<byte[]>) listReply.get(1);
if (bkeys == null) {
onMessage(enchannel, null);
} else {
bkeys.stream().map(this::encode).forEach(msg -> onMessage(enchannel, msg));
}
} else {
throw new JedisException("Unknown message type: " + firstObj);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/redis/clients/jedis/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public byte[] getRaw() {
public static enum ResponseKeyword implements Rawable {

SUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE, PUNSUBSCRIBE, MESSAGE, PMESSAGE, PONG,
SSUBSCRIBE, SUNSUBSCRIBE, SMESSAGE;
SSUBSCRIBE, SUNSUBSCRIBE, SMESSAGE, INVALIDATE;

private final byte[] raw;

Expand Down

0 comments on commit e7de9fd

Please sign in to comment.