From fe2e41fd1991bc65825a4cfbad81de9df3dba771 Mon Sep 17 00:00:00 2001 From: Marcos Lilljedahl Date: Fri, 26 Feb 2016 16:02:41 -0300 Subject: [PATCH] Add support to *scan parameters to ShardedJedis and JedisCluster Fixes #1225 Conflicts: src/main/java/redis/clients/jedis/BinaryJedisCluster.java src/main/java/redis/clients/jedis/BinaryJedisClusterCommands.java --- .../java/redis/clients/jedis/BinaryJedis.java | 6 ++ .../clients/jedis/BinaryJedisCluster.java | 62 +++++++++++++++++++ .../jedis/BinaryJedisClusterCommands.java | 13 ++++ .../clients/jedis/BinaryJedisCommands.java | 13 ++++ .../clients/jedis/BinaryShardedJedis.java | 36 +++++++++++ 5 files changed, 130 insertions(+) diff --git a/src/main/java/redis/clients/jedis/BinaryJedis.java b/src/main/java/redis/clients/jedis/BinaryJedis.java index f47525fd62..d104bea309 100644 --- a/src/main/java/redis/clients/jedis/BinaryJedis.java +++ b/src/main/java/redis/clients/jedis/BinaryJedis.java @@ -3287,10 +3287,12 @@ public ScanResult scan(final byte[] cursor, final ScanParams params) { return new ScanResult(newcursor, rawResults); } + @Override public ScanResult> hscan(final byte[] key, final byte[] cursor) { return hscan(key, cursor, new ScanParams()); } + @Override public ScanResult> hscan(final byte[] key, final byte[] cursor, final ScanParams params) { checkIsInMultiOrPipeline(); @@ -3306,10 +3308,12 @@ public ScanResult> hscan(final byte[] key, final byte[ return new ScanResult>(newcursor, results); } + @Override public ScanResult sscan(final byte[] key, final byte[] cursor) { return sscan(key, cursor, new ScanParams()); } + @Override public ScanResult sscan(final byte[] key, final byte[] cursor, final ScanParams params) { checkIsInMultiOrPipeline(); client.sscan(key, cursor, params); @@ -3319,10 +3323,12 @@ public ScanResult sscan(final byte[] key, final byte[] cursor, final Sca return new ScanResult(newcursor, rawResults); } + @Override public ScanResult zscan(final byte[] key, final byte[] cursor) { return zscan(key, cursor, new ScanParams()); } + @Override public ScanResult zscan(final byte[] key, final byte[] cursor, final ScanParams params) { checkIsInMultiOrPipeline(); client.zscan(key, cursor, params); diff --git a/src/main/java/redis/clients/jedis/BinaryJedisCluster.java b/src/main/java/redis/clients/jedis/BinaryJedisCluster.java index 688ff57878..3dbcd2da66 100644 --- a/src/main/java/redis/clients/jedis/BinaryJedisCluster.java +++ b/src/main/java/redis/clients/jedis/BinaryJedisCluster.java @@ -1954,4 +1954,66 @@ public List execute(Jedis connection) { }.runBinary(key); } + @Override + public ScanResult> hscan(final byte[] key, final byte[] cursor) { + return new JedisClusterCommand>>(connectionHandler, + maxRedirections) { + @Override + public ScanResult> execute(Jedis connection) { + return connection.hscan(key, cursor); + } + }.runBinary(key); + } + + @Override + public ScanResult> hscan(final byte[] key, final byte[] cursor, + final ScanParams params) { + return new JedisClusterCommand>>(connectionHandler, + maxRedirections) { + @Override + public ScanResult> execute(Jedis connection) { + return connection.hscan(key, cursor, params); + } + }.runBinary(key); + } + + @Override + public ScanResult sscan(final byte[] key, final byte[] cursor) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { + @Override + public ScanResult execute(Jedis connection) { + return connection.sscan(key, cursor); + } + }.runBinary(key); + } + + @Override + public ScanResult sscan(final byte[] key, final byte[] cursor, final ScanParams params) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { + @Override + public ScanResult execute(Jedis connection) { + return connection.sscan(key, cursor, params); + } + }.runBinary(key); + } + + @Override + public ScanResult zscan(final byte[] key, final byte[] cursor) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { + @Override + public ScanResult execute(Jedis connection) { + return connection.zscan(key, cursor); + } + }.runBinary(key); + } + + @Override + public ScanResult zscan(final byte[] key, final byte[] cursor, final ScanParams params) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { + @Override + public ScanResult execute(Jedis connection) { + return connection.zscan(key, cursor, params); + } + }.runBinary(key); + } } \ No newline at end of file diff --git a/src/main/java/redis/clients/jedis/BinaryJedisClusterCommands.java b/src/main/java/redis/clients/jedis/BinaryJedisClusterCommands.java index 2248dbd90a..cb8d0634a2 100644 --- a/src/main/java/redis/clients/jedis/BinaryJedisClusterCommands.java +++ b/src/main/java/redis/clients/jedis/BinaryJedisClusterCommands.java @@ -260,4 +260,17 @@ List georadius(byte[] key, double longitude, double latitude, List georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param); + + ScanResult> hscan(byte[] key, byte[] cursor); + + ScanResult> hscan(byte[] key, byte[] cursor, ScanParams params); + + ScanResult sscan(byte[] key, byte[] cursor); + + ScanResult sscan(byte[] key, byte[] cursor, ScanParams params); + + ScanResult zscan(byte[] key, byte[] cursor); + + ScanResult zscan(byte[] key, byte[] cursor, ScanParams params); + } \ No newline at end of file diff --git a/src/main/java/redis/clients/jedis/BinaryJedisCommands.java b/src/main/java/redis/clients/jedis/BinaryJedisCommands.java index fc4ade6234..3a7220ca5c 100644 --- a/src/main/java/redis/clients/jedis/BinaryJedisCommands.java +++ b/src/main/java/redis/clients/jedis/BinaryJedisCommands.java @@ -285,4 +285,17 @@ List georadius(byte[] key, double longitude, double latitude, List georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param); + + ScanResult> hscan(byte[] key, byte[] cursor); + + ScanResult> hscan(byte[] key, byte[] cursor, ScanParams params); + + ScanResult sscan(byte[] key, byte[] cursor); + + ScanResult sscan(byte[] key, byte[] cursor, ScanParams params); + + ScanResult zscan(byte[] key, byte[] cursor); + + ScanResult zscan(byte[] key, byte[] cursor, ScanParams params); + } diff --git a/src/main/java/redis/clients/jedis/BinaryShardedJedis.java b/src/main/java/redis/clients/jedis/BinaryShardedJedis.java index cbdeb06a89..601c6f2616 100644 --- a/src/main/java/redis/clients/jedis/BinaryShardedJedis.java +++ b/src/main/java/redis/clients/jedis/BinaryShardedJedis.java @@ -755,4 +755,40 @@ public List georadiusByMember(byte[] key, byte[] member, doub Jedis j = getShard(key); return j.georadiusByMember(key, member, radius, unit, param); } + + @Override + public ScanResult> hscan(byte[] key, byte[] cursor) { + Jedis j = getShard(key); + return j.hscan(key, cursor); + } + + @Override + public ScanResult> hscan(byte[] key, byte[] cursor, ScanParams params) { + Jedis j = getShard(key); + return j.hscan(key, cursor, params); + } + + @Override + public ScanResult sscan(byte[] key, byte[] cursor) { + Jedis j = getShard(key); + return j.sscan(key, cursor); + } + + @Override + public ScanResult sscan(byte[] key, byte[] cursor, ScanParams params) { + Jedis j = getShard(key); + return j.sscan(key, cursor, params); + } + + @Override + public ScanResult zscan(byte[] key, byte[] cursor) { + Jedis j = getShard(key); + return j.zscan(key, cursor); + } + + @Override + public ScanResult zscan(byte[] key, byte[] cursor, ScanParams params) { + Jedis j = getShard(key); + return j.zscan(key, cursor, params); + } }