diff --git a/src/main/java/redis/clients/jedis/StreamEntryID.java b/src/main/java/redis/clients/jedis/StreamEntryID.java index 873365ce56..fad28538da 100644 --- a/src/main/java/redis/clients/jedis/StreamEntryID.java +++ b/src/main/java/redis/clients/jedis/StreamEntryID.java @@ -8,56 +8,6 @@ public class StreamEntryID implements Comparable, Serializable { private static final long serialVersionUID = 1L; - /** - * Should be used only with XADD - * - * - * XADD mystream * field1 value1 - * - */ - public static final StreamEntryID NEW_ENTRY = new StreamEntryID() { - - private static final long serialVersionUID = 1L; - - @Override - public String toString() { - return "*"; - } - }; - - /** - * Should be used only with XGROUP CREATE - * - * - * XGROUP CREATE mystream consumer-group-name $ - * - */ - public static final StreamEntryID LAST_ENTRY = new StreamEntryID() { - - private static final long serialVersionUID = 1L; - - @Override - public String toString() { - return "$"; - } - }; - - /** - * Should be used only with XREADGROUP - * - * XREADGROUP $GroupName $ConsumerName BLOCK 2000 COUNT 10 STREAMS mystream > - * - */ - public static final StreamEntryID UNRECEIVED_ENTRY = new StreamEntryID() { - - private static final long serialVersionUID = 1L; - - @Override - public String toString() { - return ">"; - } - }; - private long time; private long sequence; @@ -126,4 +76,81 @@ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassN this.time = in.readLong(); this.sequence = in.readLong(); } + + /** + * Should be used only with XADD + * + * + * XADD mystream * field1 value1 + * + */ + public static final StreamEntryID NEW_ENTRY = new StreamEntryID() { + + private static final long serialVersionUID = 1L; + + @Override + public String toString() { + return "*"; + } + }; + + /** + * Should be used only with XGROUP CREATE + * + * + * XGROUP CREATE mystream consumer-group-name $ + * + */ + public static final StreamEntryID LAST_ENTRY = new StreamEntryID() { + + private static final long serialVersionUID = 1L; + + @Override + public String toString() { + return "$"; + } + }; + + /** + * Should be used only with XREADGROUP + * + * + * XREADGROUP $GroupName $ConsumerName BLOCK 2000 COUNT 10 STREAMS mystream > + * + */ + public static final StreamEntryID UNRECEIVED_ENTRY = new StreamEntryID() { + + private static final long serialVersionUID = 1L; + + @Override + public String toString() { + return ">"; + } + }; + + /** + * Can be used in XRANGE, XREVRANGE and XPENDING commands. + */ + public static final StreamEntryID MINIMUM_ID = new StreamEntryID() { + + private static final long serialVersionUID = 1L; + + @Override + public String toString() { + return "-"; + } + }; + + /** + * Can be used in XRANGE, XREVRANGE and XPENDING commands. + */ + public static final StreamEntryID MAXIMUM_ID = new StreamEntryID() { + + private static final long serialVersionUID = 1L; + + @Override + public String toString() { + return "+"; + } + }; } diff --git a/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java b/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java index eb8af62b09..5336f7da71 100644 --- a/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java +++ b/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java @@ -245,6 +245,8 @@ public void xrange() { List range8 = jedis.xrange("xrange-stream", (StreamEntryID) null, (StreamEntryID) null); assertEquals(3, range8.size()); + range8 = jedis.xrange("xrange-stream", StreamEntryID.MINIMUM_ID, StreamEntryID.MAXIMUM_ID); + assertEquals(3, range8.size()); } @Test @@ -381,6 +383,8 @@ public void xrevrange() { List range8 = jedis.xrevrange("xrevrange-stream", (StreamEntryID) null, (StreamEntryID) null); assertEquals(3, range8.size()); + range8 = jedis.xrevrange("xrevrange-stream", StreamEntryID.MAXIMUM_ID, StreamEntryID.MINIMUM_ID); + assertEquals(3, range8.size()); } @Test @@ -537,6 +541,14 @@ public void xpendingRange() { assertEquals("consumer1", response.get(0).getConsumerName()); assertEquals(m2, response.get(1).getID()); assertEquals("consumer2", response.get(1).getConsumerName()); + + response = jedis.xpending("xpendeing-stream", "xpendeing-group", + XPendingParams.xPendingParams(StreamEntryID.MINIMUM_ID, StreamEntryID.MAXIMUM_ID, 5)); + assertEquals(2, response.size()); + assertEquals(m1, response.get(0).getID()); + assertEquals("consumer1", response.get(0).getConsumerName()); + assertEquals(m2, response.get(1).getID()); + assertEquals("consumer2", response.get(1).getConsumerName()); } @Test