Add ScanOptions.pattern(…) accepting a byte[] pattern.

We now accept a byte array as pattern for scan operations in addition to String patterns.

Also, use binary Jedis scan method to avoid bytes to String conversion.

Closes: #2006
Original Pull Request: #2051
This commit is contained in:
Mark Paluch
2021-04-21 10:38:07 +02:00
committed by Christoph Strobl
parent 67deb3ef81
commit a525fc1fd9
5 changed files with 48 additions and 14 deletions

View File

@@ -157,10 +157,10 @@ class JedisConnectionUnitTests {
Integer.MAX_VALUE, (long) Integer.MAX_VALUE + 1L));
}
@Test // DATAREDIS-531
@Test // DATAREDIS-531, GH-2006
public void scanShouldKeepTheConnectionOpen() {
doReturn(new ScanResult<>("0", Collections.<String> emptyList())).when(jedisSpy).scan(anyString(),
doReturn(new ScanResult<>("0", Collections.<String> emptyList())).when(jedisSpy).scan(any(byte[].class),
any(ScanParams.class));
connection.scan(ScanOptions.NONE);
@@ -168,10 +168,10 @@ class JedisConnectionUnitTests {
verify(jedisSpy, never()).quit();
}
@Test // DATAREDIS-531
@Test // DATAREDIS-531, GH-2006
public void scanShouldCloseTheConnectionWhenCursorIsClosed() throws IOException {
doReturn(new ScanResult<>("0", Collections.<String> emptyList())).when(jedisSpy).scan(anyString(),
doReturn(new ScanResult<>("0", Collections.<String> emptyList())).when(jedisSpy).scan(any(byte[].class),
any(ScanParams.class));
Cursor<byte[]> cursor = connection.scan(ScanOptions.NONE);