Skip to content
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
14 changes: 11 additions & 3 deletions src/main/java/redis/clients/jedis/BinaryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1587,15 +1587,23 @@ public void xlen(final byte[] key) {
*/
@Deprecated
public void xrange(final byte[] key, final byte[] start, final byte[] end, final long count) {
sendCommand(XRANGE, key, start, end, Keyword.COUNT.getRaw(), toByteArray(count));
xrange(key, start, end, (int) count);
}

public void xrange(final byte[] key, final byte[] start, final byte[] end, final int count) {
sendCommand(XRANGE, key, start, end, Keyword.COUNT.getRaw(), toByteArray(count));
if (count > 0) {
sendCommand(XRANGE, key, start, end, Keyword.COUNT.getRaw(), toByteArray(count));
} else {
sendCommand(XRANGE, key, start, end);
}
}

public void xrevrange(final byte[] key, final byte[] end, final byte[] start, final int count) {
sendCommand(XREVRANGE, key, end, start, Keyword.COUNT.getRaw(), toByteArray(count));
if (count > 0) {
sendCommand(XREVRANGE, key, end, start, Keyword.COUNT.getRaw(), toByteArray(count));
} else {
sendCommand(XREVRANGE, key, end, start);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/redis/clients/jedis/commands/JedisCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, dou
* @param key
* @param start minimum {@link StreamEntryID} for the retrieved range, passing <code>null</code> will indicate minimum ID possible in the stream
* @param end maximum {@link StreamEntryID} for the retrieved range, passing <code>null</code> will indicate maximum ID possible in the stream
* @param count maximum number of entries returned
* @param count maximum number of entries returned, only work if count greater than zero
* @return The entries with IDs matching the specified range.
*/
List<StreamEntry> xrange(String key, StreamEntryID start, StreamEntryID end, int count);
Expand All @@ -471,7 +471,7 @@ List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, dou
* @param key
* @param start minimum {@link StreamEntryID} for the retrieved range, passing <code>null</code> will indicate minimum ID possible in the stream
* @param end maximum {@link StreamEntryID} for the retrieved range, passing <code>null</code> will indicate maximum ID possible in the stream
* @param count The entries with IDs matching the specified range.
* @param count The entries with IDs matching the specified range, only work if count greater than zero.
* @return the entries with IDs matching the specified range, from the higher ID to the lower ID matching.
*/
List<StreamEntry> xrevrange(String key, StreamEntryID end, StreamEntryID start, int count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ public void xrange() {
List<byte[]> cRange = jedis.xrange("xrange-stream".getBytes(), id1.toString().getBytes(),
id2.toString().getBytes(), 10L + Integer.MAX_VALUE);
assertEquals(2, cRange.size());

List<StreamEntry> range8 = jedis.xrange("xrange-stream", id1, id2, -1);
assertEquals(2, range8.size());
}

@Test
Expand Down Expand Up @@ -277,6 +280,8 @@ public void xrevrange() {
List<StreamEntry> range7 = jedis.xrevrange("xrevrange-stream", id2, id2, 4);
assertEquals(1, range7.size());

List<StreamEntry> range8 = jedis.xrevrange("xrevrange-stream", id2, id1, -1);
assertEquals(2, range8.size());
}

@Test
Expand Down