diff --git a/pom.xml b/pom.xml
index 7a7d83cee6..202bcf88f0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-redis
- 3.0.0-SNAPSHOT
+ 3.0.0-GH-2212-SNAPSHOT
Spring Data Redis
@@ -20,9 +20,9 @@
4.0.2
1.9.4
1.4.19
- 2.9.0
+ 2.11.1
6.1.8.RELEASE
- 3.8.0
+ 4.2.0
1.01
4.1.72.Final
spring.data.redis
diff --git a/src/main/asciidoc/new-features.adoc b/src/main/asciidoc/new-features.adoc
index 14db736982..e30c69588a 100644
--- a/src/main/asciidoc/new-features.adoc
+++ b/src/main/asciidoc/new-features.adoc
@@ -3,7 +3,12 @@
This section briefly covers items that are new and noteworthy in the latest releases.
-[[new-in-2.7.0]]
+[[new-in-3.0.0]]
+== New in Spring Data Redis 3.0
+
+* Upgrade to Jedis 4.1. Jedis 4 imposes certain limitations on transactions and pipelines and commands used in pipelines/transactions, see <>.
+
+
== New in Spring Data Redis 2.7
* Sentinel ACL authentication considering a sentinel-specific username. Setting a username enables username and password authentication requiring Redis 6.
diff --git a/src/main/asciidoc/reference/redis-cluster.adoc b/src/main/asciidoc/reference/redis-cluster.adoc
index 8edf4d667e..55f4b02fdc 100644
--- a/src/main/asciidoc/reference/redis-cluster.adoc
+++ b/src/main/asciidoc/reference/redis-cluster.adoc
@@ -47,7 +47,7 @@ public class AppConfig {
public @Bean RedisConnectionFactory connectionFactory() {
- return new JedisConnectionFactory(
+ return new LettuceConnectionFactory(
new RedisClusterConfiguration(clusterProperties.getNodes()));
}
}
diff --git a/src/main/asciidoc/reference/redis-repositories.adoc b/src/main/asciidoc/reference/redis-repositories.adoc
index 5aec8b0fbb..dcb801ee6e 100644
--- a/src/main/asciidoc/reference/redis-repositories.adoc
+++ b/src/main/asciidoc/reference/redis-repositories.adoc
@@ -58,7 +58,7 @@ public class ApplicationConfig {
@Bean
public RedisConnectionFactory connectionFactory() {
- return new JedisConnectionFactory();
+ return new LettuceConnectionFactory();
}
@Bean
@@ -843,10 +843,10 @@ class RedisOperationsProducer {
@Produces
RedisConnectionFactory redisConnectionFactory() {
- JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(new RedisStandaloneConfiguration());
- jedisConnectionFactory.afterPropertiesSet();
+ LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(new RedisStandaloneConfiguration());
+ connectionFactory.afterPropertiesSet();
- return jedisConnectionFactory;
+ return connectionFactory;
}
void disposeRedisConnectionFactory(@Disposes RedisConnectionFactory redisConnectionFactory) throws Exception {
diff --git a/src/main/asciidoc/reference/redis.adoc b/src/main/asciidoc/reference/redis.adoc
index c0976e9062..8c9801b018 100644
--- a/src/main/asciidoc/reference/redis.adoc
+++ b/src/main/asciidoc/reference/redis.adoc
@@ -118,7 +118,7 @@ Unfortunately, currently, not all connectors support all Redis features. When in
| Other Connection Features
| Singleton-connection sharing for non-blocking commands
-| `JedisShardInfo` support
+| Pipelining and Transactions mutually exclusive. Cannot use server/connection commands in pipeline/transactions.
| SSL Support
| X
@@ -130,11 +130,11 @@ Unfortunately, currently, not all connectors support all Redis features. When in
| <>
| X
-| X
+| X (Pipelining and Transactions mutually exclusive)
| <>
| X
-| X
+| X (Pipelining and Transactions mutually exclusive)
| Datatype support
| Key, String, List, Set, Sorted Set, Hash, Server, Stream, Scripting, Geo, HyperLogLog
@@ -204,7 +204,7 @@ NOTE: Netty currently supports the epoll (Linux) and kqueue (BSD/macOS) interfac
[[redis:connectors:jedis]]
=== Configuring the Jedis Connector
-https://github.com/xetorthio/jedis[Jedis] is a community-driven connector supported by the Spring Data Redis module through the `org.springframework.data.redis.connection.jedis` package.
+https://github.com/redis/jedis[Jedis] is a community-driven connector supported by the Spring Data Redis module through the `org.springframework.data.redis.connection.jedis` package.
.Add the following to the pom.xml files `dependencies` element:
@@ -223,7 +223,6 @@ https://github.com/xetorthio/jedis[Jedis] is a community-driven connector suppor
----
-
In its simplest form, the Jedis configuration looks as follow:
[source,java]
@@ -288,27 +287,27 @@ For dealing with high-availability Redis, Spring Data Redis has support for http
[source,java]
----
/**
- * Jedis
+ * Lettuce
*/
@Bean
-public RedisConnectionFactory jedisConnectionFactory() {
+public RedisConnectionFactory lettuceConnectionFactory() {
RedisSentinelConfiguration sentinelConfig = new RedisSentinelConfiguration()
.master("mymaster")
.sentinel("127.0.0.1", 26379)
.sentinel("127.0.0.1", 26380);
- return new JedisConnectionFactory(sentinelConfig);
+ return new LettuceConnectionFactory(sentinelConfig);
}
/**
- * Lettuce
+ * Jedis
*/
@Bean
-public RedisConnectionFactory lettuceConnectionFactory() {
+public RedisConnectionFactory jedisConnectionFactory() {
RedisSentinelConfiguration sentinelConfig = new RedisSentinelConfiguration()
.master("mymaster")
.sentinel("127.0.0.1", 26379)
.sentinel("127.0.0.1", 26380);
- return new LettuceConnectionFactory(sentinelConfig);
+ return new JedisConnectionFactory(sentinelConfig);
}
----
@@ -400,9 +399,9 @@ For cases where you need a certain template view, declare the view as a dependen
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
-
+
-
+
...
@@ -439,9 +438,9 @@ Since it is quite common for the keys and values stored in Redis to be `java.lan
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
-
+
-
+
...
----
diff --git a/src/main/java/org/springframework/data/redis/connection/convert/Converters.java b/src/main/java/org/springframework/data/redis/connection/convert/Converters.java
index 10ac7fd7a7..7a8bb6449d 100644
--- a/src/main/java/org/springframework/data/redis/connection/convert/Converters.java
+++ b/src/main/java/org/springframework/data/redis/connection/convert/Converters.java
@@ -58,9 +58,8 @@
* @author Mark Paluch
* @author Christoph Strobl
*/
-abstract public class Converters {
+public abstract class Converters {
- // private static final Log LOGGER = LogFactory.getLog(Converters.class);
private static final Log LOGGER = LogFactory.getLog(Converters.class);
private static final byte[] ONE = new byte[] { '1' };
diff --git a/src/main/java/org/springframework/data/redis/connection/convert/SetConverter.java b/src/main/java/org/springframework/data/redis/connection/convert/SetConverter.java
index d3e266e130..adb0646540 100644
--- a/src/main/java/org/springframework/data/redis/connection/convert/SetConverter.java
+++ b/src/main/java/org/springframework/data/redis/connection/convert/SetConverter.java
@@ -15,6 +15,7 @@
*/
package org.springframework.data.redis.connection.convert;
+import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.stream.Collectors;
@@ -48,4 +49,8 @@ public Set convert(Set source) {
return source.stream().map(itemConverter::convert).collect(Collectors.toCollection(LinkedHashSet::new));
}
+ public Set convert(Collection source) {
+ return source.stream().map(itemConverter::convert).collect(Collectors.toCollection(LinkedHashSet::new));
+ }
+
}
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClientUtils.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClientUtils.java
index e90342a0ce..7675e67524 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClientUtils.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClientUtils.java
@@ -15,23 +15,13 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.Builder;
-import redis.clients.jedis.Client;
-import redis.clients.jedis.Jedis;
-import redis.clients.jedis.Protocol.Command;
-import redis.clients.jedis.Queable;
-import redis.clients.jedis.Response;
-import redis.clients.jedis.util.SafeEncoder;
+import redis.clients.jedis.Protocol;
+import redis.clients.jedis.commands.ProtocolCommand;
-import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Set;
-import java.util.function.Function;
-import java.util.function.Supplier;
import java.util.stream.Collectors;
-import org.springframework.util.ReflectionUtils;
-
/**
* Utility class to dispatch arbitrary Redis commands using Jedis commands.
*
@@ -43,128 +33,23 @@
@SuppressWarnings({ "unchecked", "ConstantConditions" })
class JedisClientUtils {
- private static final Method GET_RESPONSE;
private static final Set KNOWN_COMMANDS;
- private static final Builder OBJECT_BUILDER;
static {
-
- GET_RESPONSE = ReflectionUtils.findMethod(Queable.class, "getResponse", Builder.class);
- ReflectionUtils.makeAccessible(GET_RESPONSE);
-
- KNOWN_COMMANDS = Arrays.stream(Command.values()).map(Enum::name).collect(Collectors.toSet());
-
- OBJECT_BUILDER = new Builder() {
- public Object build(Object data) {
- return data;
- }
-
- public String toString() {
- return "Object";
- }
- };
- }
-
- /**
- * Execute an arbitrary on the supplied {@link Jedis} instance.
- *
- * @param command the command.
- * @param keys must not be {@literal null}, may be empty.
- * @param args must not be {@literal null}, may be empty.
- * @param jedis must not be {@literal null}.
- * @return the response, can be be {@literal null}.
- */
- static T execute(String command, byte[][] keys, byte[][] args, Supplier jedis) {
- return execute(command, keys, args, jedis, it -> (T) it.getOne());
- }
-
- /**
- * Execute an arbitrary on the supplied {@link Jedis} instance.
- *
- * @param command the command.
- * @param keys must not be {@literal null}, may be empty.
- * @param args must not be {@literal null}, may be empty.
- * @param jedis must not be {@literal null}.
- * @param responseMapper must not be {@literal null}.
- * @return the response, can be be {@literal null}.
- * @since 2.1
- */
- static T execute(String command, byte[][] keys, byte[][] args, Supplier jedis,
- Function responseMapper) {
-
- byte[][] commandArgs = getCommandArguments(keys, args);
-
- Client client = sendCommand(command, commandArgs, jedis.get());
-
- return responseMapper.apply(client);
+ KNOWN_COMMANDS = Arrays.stream(Protocol.Command.values()).map(Enum::name).collect(Collectors.toSet());
}
- /**
- * Send a Redis command and retrieve the {@link Client} for response retrieval.
- *
- * @param command the command.
- * @param args must not be {@literal null}, may be empty.
- * @param jedis must not be {@literal null}.
- * @return the {@link Client} instance used to send the command.
- */
- static Client sendCommand(String command, byte[][] args, Jedis jedis) {
-
- Client client = jedis.getClient();
-
- sendCommand(client, command, args);
-
- return client;
- }
-
- private static void sendCommand(Client client, String command, byte[][] args) {
+ public static ProtocolCommand getCommand(String command) {
if (isKnownCommand(command)) {
- client.sendCommand(Command.valueOf(command.trim().toUpperCase()), args);
- } else {
- client.sendCommand(() -> SafeEncoder.encode(command.trim().toUpperCase()), args);
+ return Protocol.Command.valueOf(command.trim().toUpperCase());
}
+
+ return () -> JedisConverters.toBytes(command);
}
private static boolean isKnownCommand(String command) {
return KNOWN_COMMANDS.contains(command);
}
- private static byte[][] getCommandArguments(byte[][] keys, byte[][] args) {
-
- if (keys.length == 0) {
- return args;
- }
-
- if (args.length == 0) {
- return keys;
- }
-
- byte[][] commandArgs = new byte[keys.length + args.length][];
-
- System.arraycopy(keys, 0, commandArgs, 0, keys.length);
- System.arraycopy(args, 0, commandArgs, keys.length, args.length);
-
- return commandArgs;
- }
-
- /**
- * @param jedis the client instance.
- * @return {@literal true} if the connection has entered {@literal MULTI} state.
- */
- static boolean isInMulti(Jedis jedis) {
- return jedis.getClient().isInMulti();
- }
-
- /**
- * Retrieve the {@link Response} object from a {@link redis.clients.jedis.Transaction} or a
- * {@link redis.clients.jedis.Pipeline} for response synchronization.
- *
- * @param target a {@link redis.clients.jedis.Transaction} or {@link redis.clients.jedis.Pipeline}, must not be
- * {@literal null}.
- * @return the {@link Response} wrapper object.
- */
- static Response getResponse(Object target) {
- return (Response) ReflectionUtils.invokeMethod(GET_RESPONSE, target, OBJECT_BUILDER);
- }
-
}
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java
index 6ffcf80c2e..6f02406d1f 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java
@@ -15,13 +15,12 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.BinaryJedis;
-import redis.clients.jedis.Client;
+import redis.clients.jedis.Connection;
+import redis.clients.jedis.ConnectionPool;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
-import redis.clients.jedis.JedisClusterConnectionHandler;
-import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.providers.ClusterConnectionProvider;
import java.time.Duration;
import java.util.ArrayList;
@@ -33,7 +32,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.function.Function;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -78,8 +76,6 @@ public class JedisClusterConnection implements RedisClusterConnection {
private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new FallbackExceptionTranslationStrategy(
JedisExceptionConverter.INSTANCE);
- private static final byte[][] EMPTY_2D_BYTE_ARRAY = new byte[0][];
-
private final Log log = LogFactory.getLog(getClass());
private final JedisCluster cluster;
@@ -97,7 +93,7 @@ public class JedisClusterConnection implements RedisClusterConnection {
private boolean closed;
private final ClusterTopologyProvider topologyProvider;
- private ClusterCommandExecutor clusterCommandExecutor;
+ private final ClusterCommandExecutor clusterCommandExecutor;
private final boolean disposeClusterCommandExecutorOnClose;
private volatile @Nullable JedisSubscription subscription;
@@ -120,8 +116,11 @@ public JedisClusterConnection(JedisCluster cluster) {
disposeClusterCommandExecutorOnClose = true;
try {
- DirectFieldAccessor dfa = new DirectFieldAccessor(cluster);
- clusterCommandExecutor.setMaxRedirects((Integer) dfa.getPropertyValue("maxRedirections"));
+
+ DirectFieldAccessor executorDfa = new DirectFieldAccessor(cluster);
+ Object custerCommandExecutor = executorDfa.getPropertyValue("executor");
+ DirectFieldAccessor dfa = new DirectFieldAccessor(custerCommandExecutor);
+ clusterCommandExecutor.setMaxRedirects((Integer) dfa.getPropertyValue("maxRedirects"));
} catch (Exception e) {
// ignore it and work with the executor default
}
@@ -168,20 +167,14 @@ public Object execute(String command, byte[]... args) {
Assert.notNull(command, "Command must not be null!");
Assert.notNull(args, "Args must not be null!");
- return clusterCommandExecutor
- .executeCommandOnArbitraryNode((JedisClusterCommandCallback) client -> JedisClientUtils.execute(command,
- EMPTY_2D_BYTE_ARRAY, args, () -> client))
+ return clusterCommandExecutor.executeCommandOnArbitraryNode(
+ (JedisClusterCommandCallback) client -> client.sendCommand(JedisClientUtils.getCommand(command), args))
.getValue();
}
@Nullable
@Override
public T execute(String command, byte[] key, Collection args) {
- return execute(command, key, args, it -> (T) it.getOne());
- }
-
- @Nullable
- T execute(String command, byte[] key, Collection args, Function responseMapper) {
Assert.notNull(command, "Command must not be null!");
Assert.notNull(key, "Key must not be null!");
@@ -191,8 +184,9 @@ T execute(String command, byte[] key, Collection args, Function) client -> JedisClientUtils
- .execute(command, EMPTY_2D_BYTE_ARRAY, commandArgs, () -> client, responseMapper), keyMaster).getValue();
+ return clusterCommandExecutor.executeCommandOnSingleNode((JedisClusterCommandCallback) client -> {
+ return (T) client.sendCommand(JedisClientUtils.getCommand(command), commandArgs);
+ }, keyMaster).getValue();
}
private static byte[][] getCommandArguments(byte[] key, Collection args) {
@@ -238,9 +232,9 @@ public List execute(String command, Collection keys, Collection) (client, key) -> {
- return JedisClientUtils.execute(command, new byte[][] { key }, args.toArray(new byte[args.size()][]),
- () -> client);
+ return (T) client.sendCommand(JedisClientUtils.getCommand(command), getCommandArguments(key, args));
}, keys).resultsAsList();
+
}
@Override
@@ -409,18 +403,13 @@ public void select(int dbIndex) {
@Override
public byte[] echo(byte[] message) {
-
- try {
- return cluster.echo(message);
- } catch (Exception ex) {
- throw convertJedisAccessException(ex);
- }
+ throw new InvalidDataAccessApiUsageException("Echo not supported in cluster mode.");
}
@Override
public String ping() {
- return !clusterCommandExecutor.executeCommandOnAllNodes((JedisClusterCommandCallback) BinaryJedis::ping)
+ return !clusterCommandExecutor.executeCommandOnAllNodes((JedisClusterCommandCallback) Jedis::ping)
.resultsAsList().isEmpty() ? "PONG" : null;
}
@@ -428,8 +417,8 @@ public String ping() {
@Override
public String ping(RedisClusterNode node) {
- return clusterCommandExecutor
- .executeCommandOnSingleNode((JedisClusterCommandCallback) BinaryJedis::ping, node).getValue();
+ return clusterCommandExecutor.executeCommandOnSingleNode((JedisClusterCommandCallback) Jedis::ping, node)
+ .getValue();
}
/*
@@ -552,8 +541,10 @@ public void clusterReplicate(RedisClusterNode master, RedisClusterNode replica)
@Override
public Integer clusterGetSlotForKey(byte[] key) {
- return clusterCommandExecutor.executeCommandOnArbitraryNode((JedisClusterCommandCallback) client -> client
- .clusterKeySlot(JedisConverters.toString(key)).intValue()).getValue();
+ return clusterCommandExecutor
+ .executeCommandOnArbitraryNode(
+ (JedisClusterCommandCallback) client -> (int) client.clusterKeySlot(JedisConverters.toString(key)))
+ .getValue();
}
@Override
@@ -662,17 +653,17 @@ public boolean isPipelined() {
@Override
public void openPipeline() {
- throw new UnsupportedOperationException("Pipeline is currently not supported for JedisClusterConnection.");
+ throw new InvalidDataAccessApiUsageException("Pipeline is not supported for JedisClusterConnection.");
}
@Override
public List closePipeline() throws RedisPipelineException {
- throw new UnsupportedOperationException("Pipeline is currently not supported for JedisClusterConnection.");
+ throw new InvalidDataAccessApiUsageException("Pipeline is not supported for JedisClusterConnection.");
}
@Override
public RedisSentinelConnection getSentinelConnection() {
- throw new UnsupportedOperationException("Sentinel is currently not supported for JedisClusterConnection.");
+ throw new InvalidDataAccessApiUsageException("Sentinel is not supported for JedisClusterConnection.");
}
@Override
@@ -709,7 +700,7 @@ static class JedisClusterNodeResourceProvider implements ClusterNodeResourceProv
private final JedisCluster cluster;
private final ClusterTopologyProvider topologyProvider;
- private final JedisClusterConnectionHandler connectionHandler;
+ private final ClusterConnectionProvider connectionHandler;
/**
* Creates new {@link JedisClusterNodeResourceProvider}.
@@ -726,7 +717,7 @@ static class JedisClusterNodeResourceProvider implements ClusterNodeResourceProv
PropertyAccessor accessor = new DirectFieldAccessFallbackBeanWrapper(cluster);
this.connectionHandler = accessor.isReadableProperty("connectionHandler")
- ? (JedisClusterConnectionHandler) accessor.getPropertyValue("connectionHandler")
+ ? (ClusterConnectionProvider) accessor.getPropertyValue("connectionHandler")
: null;
} else {
this.connectionHandler = null;
@@ -739,23 +730,23 @@ public Jedis getResourceForSpecificNode(RedisClusterNode node) {
Assert.notNull(node, "Cannot get Pool for 'null' node!");
- JedisPool pool = getResourcePoolForSpecificNode(node);
+ ConnectionPool pool = getResourcePoolForSpecificNode(node);
if (pool != null) {
- return pool.getResource();
+ return new Jedis(pool.getResource());
}
- Jedis connection = getConnectionForSpecificNode(node);
+ Connection connection = getConnectionForSpecificNode(node);
if (connection != null) {
- return connection;
+ return new Jedis(connection);
}
throw new DataAccessResourceFailureException(String.format("Node %s is unknown to cluster", node));
}
- private JedisPool getResourcePoolForSpecificNode(RedisClusterNode node) {
+ private ConnectionPool getResourcePoolForSpecificNode(RedisClusterNode node) {
- Map clusterNodes = cluster.getClusterNodes();
+ Map clusterNodes = cluster.getClusterNodes();
if (clusterNodes.containsKey(node.asString())) {
return clusterNodes.get(node.asString());
}
@@ -763,7 +754,7 @@ private JedisPool getResourcePoolForSpecificNode(RedisClusterNode node) {
return null;
}
- private Jedis getConnectionForSpecificNode(RedisClusterNode node) {
+ private Connection getConnectionForSpecificNode(RedisClusterNode node) {
RedisClusterNode member = topologyProvider.getTopology().lookup(node);
@@ -773,7 +764,7 @@ private Jedis getConnectionForSpecificNode(RedisClusterNode node) {
}
if (member != null && connectionHandler != null) {
- return connectionHandler.getConnectionFromNode(new HostAndPort(member.getHost(), member.getPort()));
+ return connectionHandler.getConnection(new HostAndPort(member.getHost(), member.getPort()));
}
return null;
@@ -835,15 +826,15 @@ public ClusterTopology getTopology() {
Map errors = new LinkedHashMap<>();
- List> list = new ArrayList<>(cluster.getClusterNodes().entrySet());
+ List> list = new ArrayList<>(cluster.getClusterNodes().entrySet());
Collections.shuffle(list);
- for (Entry entry : list) {
+ for (Entry entry : list) {
- try (Jedis jedis = entry.getValue().getResource()) {
+ try (Connection connection = entry.getValue().getResource()) {
time = System.currentTimeMillis();
- Set nodes = Converters.toSetOfRedisClusterNodes(jedis.clusterNodes());
+ Set nodes = Converters.toSetOfRedisClusterNodes(new Jedis(connection).clusterNodes());
synchronized (lock) {
cached = new ClusterTopology(nodes);
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterGeoCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterGeoCommands.java
index 94c1033c82..30911ea8bd 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterGeoCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterGeoCommands.java
@@ -16,8 +16,9 @@
package org.springframework.data.redis.connection.jedis;
import redis.clients.jedis.GeoCoordinate;
-import redis.clients.jedis.GeoUnit;
+import redis.clients.jedis.args.GeoUnit;
import redis.clients.jedis.params.GeoRadiusParam;
+import redis.clients.jedis.params.GeoSearchParam;
import java.util.HashMap;
import java.util.List;
@@ -238,13 +239,37 @@ public Long geoRemove(byte[] key, byte[]... members) {
@Override
public GeoResults> geoSearch(byte[] key, GeoReference reference, GeoShape predicate,
GeoSearchCommandArgs args) {
- throw new UnsupportedOperationException("GEOSEARCH not supported through Jedis");
+
+ Assert.notNull(key, "Key must not be null!");
+ GeoSearchParam params = JedisConverters.toGeoSearchParams(reference, predicate, args);
+
+ try {
+
+ return JedisConverters.geoRadiusResponseToGeoResultsConverter(predicate.getMetric())
+ .convert(connection.getCluster().geosearch(key, params));
+ } catch (Exception ex) {
+ throw convertJedisAccessException(ex);
+ }
}
@Override
public Long geoSearchStore(byte[] destKey, byte[] key, GeoReference reference, GeoShape predicate,
GeoSearchStoreCommandArgs args) {
- throw new UnsupportedOperationException("GEOSEARCHSTORE not supported through Jedis");
+
+ Assert.notNull(destKey, "Destination Key must not be null!");
+ Assert.notNull(key, "Key must not be null!");
+ GeoSearchParam params = JedisConverters.toGeoSearchParams(reference, predicate, args);
+
+ try {
+
+ if (args.isStoreDistance()) {
+ return connection.getCluster().geosearchStoreStoreDist(destKey, key, params);
+ }
+
+ return connection.getCluster().geosearchStore(destKey, key, params);
+ } catch (Exception ex) {
+ throw convertJedisAccessException(ex);
+ }
}
private DataAccessException convertJedisAccessException(Exception ex) {
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java
index f7628823c2..d48b78109b 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java
@@ -15,7 +15,8 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.ScanParams;
+import redis.clients.jedis.params.ScanParams;
+import redis.clients.jedis.resps.ScanResult;
import java.util.ArrayList;
import java.util.Collections;
@@ -278,8 +279,8 @@ protected ScanIteration> doScan(long cursorId, ScanOptions
ScanParams params = JedisConverters.toScanParams(options);
- redis.clients.jedis.ScanResult> result = connection.getCluster().hscan(key,
- JedisConverters.toBytes(cursorId), params);
+ ScanResult> result = connection.getCluster().hscan(key, JedisConverters.toBytes(cursorId),
+ params);
return new ScanIteration<>(Long.valueOf(result.getCursor()), result.getResult());
}
}.open();
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterKeyCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterKeyCommands.java
index 526aea0acd..578f0d5408 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterKeyCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterKeyCommands.java
@@ -15,8 +15,9 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.BinaryJedis;
-import redis.clients.jedis.ScanParams;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.params.ScanParams;
+import redis.clients.jedis.resps.ScanResult;
import java.time.Duration;
import java.util.ArrayList;
@@ -179,7 +180,7 @@ Cursor scan(RedisClusterNode node, ScanOptions options) {
protected ScanIteration doScan(long cursorId, ScanOptions options) {
ScanParams params = JedisConverters.toScanParams(options);
- redis.clients.jedis.ScanResult result = client.scan(Long.toString(cursorId), params);
+ ScanResult result = client.scan(Long.toString(cursorId), params);
return new ScanIteration<>(Long.valueOf(result.getCursor()),
JedisConverters.stringListToByteList().convert(result.getResult()));
}
@@ -277,11 +278,8 @@ public Boolean expire(byte[] key, long seconds) {
Assert.notNull(key, "Key must not be null!");
- if (seconds > Integer.MAX_VALUE) {
- throw new UnsupportedOperationException("Jedis does not support seconds exceeding Integer.MAX_VALUE.");
- }
try {
- return JedisConverters.toBoolean(connection.getCluster().expire(key, Long.valueOf(seconds).intValue()));
+ return JedisConverters.toBoolean(connection.getCluster().expire(key, seconds));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -337,7 +335,7 @@ public Boolean persist(byte[] key) {
@Override
public Boolean move(byte[] key, int dbIndex) {
- throw new UnsupportedOperationException("Cluster mode does not allow moving keys.");
+ throw new InvalidDataAccessApiUsageException("Cluster mode does not allow moving keys.");
}
@Override
@@ -404,14 +402,10 @@ public void restore(byte[] key, long ttlInMillis, byte[] serializedValue, boolea
Assert.notNull(key, "Key must not be null!");
Assert.notNull(serializedValue, "Serialized value must not be null!");
- if (ttlInMillis > Integer.MAX_VALUE) {
- throw new UnsupportedOperationException("Jedis does not support ttlInMillis exceeding Integer.MAX_VALUE.");
- }
-
connection.getClusterCommandExecutor().executeCommandOnSingleNode((JedisClusterCommandCallback) client -> {
if (!replace) {
- return client.restore(key, Long.valueOf(ttlInMillis).intValue(), serializedValue);
+ return client.restore(key, ttlInMillis, serializedValue);
}
return JedisConverters.toString(this.connection.execute("RESTORE", key,
@@ -472,7 +466,7 @@ public Long exists(byte[]... keys) {
}
return connection.getClusterCommandExecutor()
- .executeMultiKeyCommand((JedisMultiKeyClusterCommandCallback) BinaryJedis::exists, Arrays.asList(keys))
+ .executeMultiKeyCommand((JedisMultiKeyClusterCommandCallback) Jedis::exists, Arrays.asList(keys))
.resultsAsList().stream().mapToLong(val -> ObjectUtils.nullSafeEquals(val, Boolean.TRUE) ? 1 : 0).sum();
}
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterScriptingCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterScriptingCommands.java
index 317959aef8..d55dd8a3bd 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterScriptingCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterScriptingCommands.java
@@ -15,7 +15,7 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.BinaryJedis;
+import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import java.util.List;
@@ -43,8 +43,8 @@ class JedisClusterScriptingCommands implements RedisScriptingCommands {
public void scriptFlush() {
try {
- connection.getClusterCommandExecutor().executeCommandOnAllNodes(
- (JedisClusterConnection.JedisClusterCommandCallback) BinaryJedis::scriptFlush);
+ connection.getClusterCommandExecutor()
+ .executeCommandOnAllNodes((JedisClusterConnection.JedisClusterCommandCallback) Jedis::scriptFlush);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -54,8 +54,8 @@ public void scriptFlush() {
public void scriptKill() {
try {
- connection.getClusterCommandExecutor().executeCommandOnAllNodes(
- (JedisClusterConnection.JedisClusterCommandCallback) BinaryJedis::scriptKill);
+ connection.getClusterCommandExecutor()
+ .executeCommandOnAllNodes((JedisClusterConnection.JedisClusterCommandCallback) Jedis::scriptKill);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -89,8 +89,7 @@ public T eval(byte[] script, ReturnType returnType, int numKeys, byte[]... k
Assert.notNull(script, "Script must not be null!");
try {
- return (T) new JedisScriptReturnConverter(returnType)
- .convert(getCluster().eval(script, JedisConverters.toBytes(numKeys), keysAndArgs));
+ return (T) new JedisScriptReturnConverter(returnType).convert(getCluster().eval(script, numKeys, keysAndArgs));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterServerCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterServerCommands.java
index 93e7ca42d9..015570739a 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterServerCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterServerCommands.java
@@ -15,7 +15,6 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.BinaryJedis;
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
@@ -54,30 +53,30 @@ class JedisClusterServerCommands implements RedisClusterServerCommands {
@Override
public void bgReWriteAof(RedisClusterNode node) {
- executeCommandOnSingleNode(BinaryJedis::bgrewriteaof, node);
+ executeCommandOnSingleNode(Jedis::bgrewriteaof, node);
}
@Override
public void bgReWriteAof() {
connection.getClusterCommandExecutor()
- .executeCommandOnAllNodes((JedisClusterCommandCallback) BinaryJedis::bgrewriteaof);
+ .executeCommandOnAllNodes((JedisClusterCommandCallback) Jedis::bgrewriteaof);
}
@Override
public void bgSave() {
connection.getClusterCommandExecutor()
- .executeCommandOnAllNodes((JedisClusterCommandCallback) BinaryJedis::bgsave);
+ .executeCommandOnAllNodes((JedisClusterCommandCallback) Jedis::bgsave);
}
@Override
public void bgSave(RedisClusterNode node) {
- executeCommandOnSingleNode(BinaryJedis::bgsave, node);
+ executeCommandOnSingleNode(Jedis::bgsave, node);
}
@Override
public Long lastSave() {
- List result = new ArrayList<>(executeCommandOnAllNodes(BinaryJedis::lastsave).resultsAsList());
+ List result = new ArrayList<>(executeCommandOnAllNodes(Jedis::lastsave).resultsAsList());
if (CollectionUtils.isEmpty(result)) {
return null;
@@ -89,23 +88,23 @@ public Long lastSave() {
@Override
public Long lastSave(RedisClusterNode node) {
- return executeCommandOnSingleNode(BinaryJedis::lastsave, node).getValue();
+ return executeCommandOnSingleNode(Jedis::lastsave, node).getValue();
}
@Override
public void save() {
- executeCommandOnAllNodes(BinaryJedis::save);
+ executeCommandOnAllNodes(Jedis::save);
}
@Override
public void save(RedisClusterNode node) {
- executeCommandOnSingleNode(BinaryJedis::save, node);
+ executeCommandOnSingleNode(Jedis::save, node);
}
@Override
public Long dbSize() {
- Collection dbSizes = executeCommandOnAllNodes(BinaryJedis::dbSize).resultsAsList();
+ Collection dbSizes = executeCommandOnAllNodes(Jedis::dbSize).resultsAsList();
if (CollectionUtils.isEmpty(dbSizes)) {
return 0L;
@@ -120,12 +119,12 @@ public Long dbSize() {
@Override
public Long dbSize(RedisClusterNode node) {
- return executeCommandOnSingleNode(BinaryJedis::dbSize, node).getValue();
+ return executeCommandOnSingleNode(Jedis::dbSize, node).getValue();
}
@Override
public void flushDb() {
- executeCommandOnAllNodes(BinaryJedis::flushDB);
+ executeCommandOnAllNodes(Jedis::flushDB);
}
@Override
@@ -135,7 +134,7 @@ public void flushDb(FlushOption option) {
@Override
public void flushDb(RedisClusterNode node) {
- executeCommandOnSingleNode(BinaryJedis::flushDB, node);
+ executeCommandOnSingleNode(Jedis::flushDB, node);
}
@Override
@@ -146,19 +145,18 @@ public void flushDb(RedisClusterNode node, FlushOption option) {
@Override
public void flushAll() {
connection.getClusterCommandExecutor()
- .executeCommandOnAllNodes((JedisClusterCommandCallback) BinaryJedis::flushAll);
+ .executeCommandOnAllNodes((JedisClusterCommandCallback) Jedis::flushAll);
}
@Override
public void flushAll(FlushOption option) {
- connection.getClusterCommandExecutor()
- .executeCommandOnAllNodes(
- (JedisClusterCommandCallback) it -> it.flushAll(JedisConverters.toFlushMode(option)));
+ connection.getClusterCommandExecutor().executeCommandOnAllNodes(
+ (JedisClusterCommandCallback) it -> it.flushAll(JedisConverters.toFlushMode(option)));
}
@Override
public void flushAll(RedisClusterNode node) {
- executeCommandOnSingleNode(BinaryJedis::flushAll, node);
+ executeCommandOnSingleNode(Jedis::flushAll, node);
}
@Override
@@ -187,7 +185,7 @@ public Properties info() {
@Override
public Properties info(RedisClusterNode node) {
- return JedisConverters.toProperties(executeCommandOnSingleNode(BinaryJedis::info, node).getValue());
+ return JedisConverters.toProperties(executeCommandOnSingleNode(Jedis::info, node).getValue());
}
@Override
@@ -221,13 +219,18 @@ public Properties info(RedisClusterNode node, String section) {
@Override
public void shutdown() {
- connection.getClusterCommandExecutor()
- .executeCommandOnAllNodes((JedisClusterCommandCallback) BinaryJedis::shutdown);
+ connection.getClusterCommandExecutor().executeCommandOnAllNodes((JedisClusterCommandCallback) jedis -> {
+ jedis.shutdown();
+ return null;
+ });
}
@Override
public void shutdown(RedisClusterNode node) {
- executeCommandOnSingleNode(BinaryJedis::shutdown, node);
+ executeCommandOnSingleNode(jedis -> {
+ jedis.shutdown();
+ return null;
+ }, node);
}
@Override
@@ -297,23 +300,23 @@ public void setConfig(RedisClusterNode node, String param, String value) {
@Override
public void resetConfigStats() {
connection.getClusterCommandExecutor()
- .executeCommandOnAllNodes((JedisClusterCommandCallback) BinaryJedis::configResetStat);
+ .executeCommandOnAllNodes((JedisClusterCommandCallback) Jedis::configResetStat);
}
@Override
public void rewriteConfig() {
connection.getClusterCommandExecutor()
- .executeCommandOnAllNodes((JedisClusterCommandCallback) BinaryJedis::configRewrite);
+ .executeCommandOnAllNodes((JedisClusterCommandCallback) Jedis::configRewrite);
}
@Override
public void resetConfigStats(RedisClusterNode node) {
- executeCommandOnSingleNode(BinaryJedis::configResetStat, node);
+ executeCommandOnSingleNode(Jedis::configResetStat, node);
}
@Override
public void rewriteConfig(RedisClusterNode node) {
- executeCommandOnSingleNode(BinaryJedis::configRewrite, node);
+ executeCommandOnSingleNode(Jedis::configRewrite, node);
}
@Override
@@ -321,7 +324,7 @@ public Long time(TimeUnit timeUnit) {
return convertListOfStringToTime(
connection.getClusterCommandExecutor()
- .executeCommandOnArbitraryNode((JedisClusterCommandCallback>) BinaryJedis::time).getValue(),
+ .executeCommandOnArbitraryNode((JedisClusterCommandCallback>) Jedis::time).getValue(),
timeUnit);
}
@@ -330,7 +333,7 @@ public Long time(RedisClusterNode node, TimeUnit timeUnit) {
return convertListOfStringToTime(
connection.getClusterCommandExecutor()
- .executeCommandOnSingleNode((JedisClusterCommandCallback>) BinaryJedis::time, node).getValue(),
+ .executeCommandOnSingleNode((JedisClusterCommandCallback>) Jedis::time, node).getValue(),
timeUnit);
}
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterSetCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterSetCommands.java
index caef5551da..b4698c240b 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterSetCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterSetCommands.java
@@ -15,7 +15,8 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.ScanParams;
+import redis.clients.jedis.params.ScanParams;
+import redis.clients.jedis.resps.ScanResult;
import java.util.ArrayList;
import java.util.Arrays;
@@ -396,8 +397,7 @@ public Cursor sScan(byte[] key, ScanOptions options) {
protected ScanIteration doScan(long cursorId, ScanOptions options) {
ScanParams params = JedisConverters.toScanParams(options);
- redis.clients.jedis.ScanResult result = connection.getCluster().sscan(key,
- JedisConverters.toBytes(cursorId), params);
+ ScanResult result = connection.getCluster().sscan(key, JedisConverters.toBytes(cursorId), params);
return new ScanIteration<>(Long.parseLong(result.getCursor()), result.getResult());
}
}.open();
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStreamCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStreamCommands.java
index c0092fde95..e73c7c4984 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStreamCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStreamCommands.java
@@ -19,7 +19,11 @@
import redis.clients.jedis.BuilderFactory;
import redis.clients.jedis.params.XAddParams;
+import redis.clients.jedis.params.XClaimParams;
+import redis.clients.jedis.params.XReadGroupParams;
+import redis.clients.jedis.params.XReadParams;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -73,7 +77,7 @@ public RecordId xAdd(MapRecord record, XAddOptions optio
Assert.notNull(record, "Record must not be null!");
Assert.notNull(record.getStream(), "Stream must not be null!");
- XAddParams params = StreamConverters.toXAddParams(record, options);
+ XAddParams params = StreamConverters.toXAddParams(record.getId(), options);
try {
return RecordId
@@ -85,7 +89,26 @@ public RecordId xAdd(MapRecord record, XAddOptions optio
@Override
public List xClaimJustId(byte[] key, String group, String newOwner, XClaimOptions options) {
- throw new UnsupportedOperationException("JedisCluster does not support xClaimJustId.");
+
+ Assert.notNull(key, "Key must not be null!");
+ Assert.notNull(group, "Group must not be null!");
+ Assert.notNull(newOwner, "NewOwner must not be null!");
+
+ long minIdleTime = options.getMinIdleTime() == null ? -1L : options.getMinIdleTime().toMillis();
+
+ XClaimParams xClaimParams = StreamConverters.toXClaimParams(options);
+ try {
+
+ List ids = connection.getCluster().xclaimJustId(key, JedisConverters.toBytes(group),
+ JedisConverters.toBytes(newOwner), minIdleTime, xClaimParams, entryIdsToBytes(options.getIds()));
+
+ List recordIds = new ArrayList<>(ids.size());
+ ids.forEach(it -> recordIds.add(RecordId.of(JedisConverters.toString(it))));
+
+ return recordIds;
+ } catch (Exception ex) {
+ throw convertJedisAccessException(ex);
+ }
}
@Override
@@ -96,13 +119,11 @@ public List xClaim(byte[] key, String group, String newOwner, XClaim
Assert.notNull(newOwner, "NewOwner must not be null!");
long minIdleTime = options.getMinIdleTime() == null ? -1L : options.getMinIdleTime().toMillis();
- int retryCount = options.getRetryCount() == null ? -1 : options.getRetryCount().intValue();
- long unixTime = options.getUnixTime() == null ? -1L : options.getUnixTime().toEpochMilli();
+ XClaimParams xClaimParams = StreamConverters.toXClaimParams(options);
try {
- return convertToByteRecord(key,
- connection.getCluster().xclaim(key, JedisConverters.toBytes(group), JedisConverters.toBytes(newOwner),
- minIdleTime, unixTime, retryCount, options.isForce(), entryIdsToBytes(options.getIds())));
+ return convertToByteRecord(key, connection.getCluster().xclaim(key, JedisConverters.toBytes(group),
+ JedisConverters.toBytes(newOwner), minIdleTime, xClaimParams, entryIdsToBytes(options.getIds())));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -170,17 +191,40 @@ public Boolean xGroupDestroy(byte[] key, String groupName) {
@Override
public StreamInfo.XInfoStream xInfo(byte[] key) {
- throw new UnsupportedOperationException("JedisCluster does not support XINFO.");
+
+ Assert.notNull(key, "Key must not be null!");
+
+ try {
+ return StreamInfo.XInfoStream.fromList((List) connection.getCluster().xinfoStream(key));
+ } catch (Exception ex) {
+ throw convertJedisAccessException(ex);
+ }
}
@Override
public StreamInfo.XInfoGroups xInfoGroups(byte[] key) {
- throw new UnsupportedOperationException("JedisCluster does not support XINFO.");
+
+ Assert.notNull(key, "Key must not be null!");
+
+ try {
+ return StreamInfo.XInfoGroups.fromList(connection.getCluster().xinfoGroups(key));
+ } catch (Exception ex) {
+ throw convertJedisAccessException(ex);
+ }
}
@Override
public StreamInfo.XInfoConsumers xInfoConsumers(byte[] key, String groupName) {
- throw new UnsupportedOperationException("JedisCluster does not support XINFO.");
+
+ Assert.notNull(key, "Key must not be null!");
+ Assert.notNull(groupName, "GroupName must not be null!");
+
+ try {
+ return StreamInfo.XInfoConsumers.fromList(groupName,
+ connection.getCluster().xinfoConsumers(key, JedisConverters.toBytes(groupName)));
+ } catch (Exception ex) {
+ throw convertJedisAccessException(ex);
+ }
}
@Override
@@ -197,7 +241,21 @@ public Long xLen(byte[] key) {
@Override
public PendingMessagesSummary xPending(byte[] key, String groupName) {
- throw new UnsupportedOperationException("Jedis does not support returning PendingMessagesSummary.");
+
+ Assert.notNull(key, "Key must not be null!");
+ Assert.notNull(groupName, "GroupName must not be null!");
+
+ byte[] group = JedisConverters.toBytes(groupName);
+
+ try {
+
+ Object response = connection.getCluster().xpending(key, group);
+
+ return StreamConverters.toPendingMessagesSummary(groupName, response);
+ } catch (Exception ex) {
+ throw convertJedisAccessException(ex);
+ }
+
}
@Override
@@ -245,12 +303,11 @@ public List xRead(StreamReadOptions readOptions, StreamOffset xread = connection.getCluster().xread(count, block, toStreamOffsets(streams));
+ List xread = connection.getCluster().xread(xReadParams, toStreamOffsets(streams));
if (xread == null) {
return Collections.emptyList();
@@ -270,13 +327,12 @@ public List xReadGroup(Consumer consumer, StreamReadOptions readOpti
Assert.notNull(readOptions, "StreamReadOptions must not be null!");
Assert.notNull(streams, "StreamOffsets must not be null!");
- long block = readOptions.getBlock() == null ? -1L : readOptions.getBlock();
- int count = readOptions.getCount() == null ? -1 : readOptions.getCount().intValue();
+ XReadGroupParams xReadParams = StreamConverters.toXReadGroupParams(readOptions);
try {
List xread = connection.getCluster().xreadGroup(JedisConverters.toBytes(consumer.getGroup()),
- JedisConverters.toBytes(consumer.getName()), count, block, readOptions.isNoack(), toStreamOffsets(streams));
+ JedisConverters.toBytes(consumer.getName()), xReadParams, toStreamOffsets(streams));
if (xread == null) {
return Collections.emptyList();
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStringCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStringCommands.java
index 68599f7b75..617fbc52cd 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStringCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStringCommands.java
@@ -15,8 +15,7 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.BinaryJedis;
-import redis.clients.jedis.Connection;
+import redis.clients.jedis.Jedis;
import redis.clients.jedis.params.SetParams;
import java.util.ArrayList;
@@ -116,7 +115,7 @@ public List mGet(byte[]... keys) {
}
return connection.getClusterCommandExecutor()
- .executeMultiKeyCommand((JedisMultiKeyClusterCommandCallback) BinaryJedis::get, Arrays.asList(keys))
+ .executeMultiKeyCommand((JedisMultiKeyClusterCommandCallback) Jedis::get, Arrays.asList(keys))
.resultsAsListSortBy(keys);
}
@@ -393,7 +392,7 @@ public List bitField(byte[] key, BitFieldSubCommands subCommands) {
byte[][] args = JedisConverters.toBitfieldCommandArguments(subCommands);
try {
- return connection.execute("BITFIELD", key, Arrays.asList(args), Connection::getIntegerMultiBulkReply);
+ return connection.getCluster().bitfield(key, args);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java
index 9e92134a1c..e4376b14b5 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java
@@ -15,10 +15,12 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.ScanParams;
-import redis.clients.jedis.ZParams;
+import redis.clients.jedis.params.ScanParams;
+import redis.clients.jedis.params.ZParams;
+import redis.clients.jedis.resps.ScanResult;
import java.util.ArrayList;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -49,7 +51,7 @@
*/
class JedisClusterZSetCommands implements RedisZSetCommands {
- private static final SetConverter TUPLE_SET_CONVERTER = new SetConverter<>(
+ private static final SetConverter TUPLE_SET_CONVERTER = new SetConverter<>(
JedisConverters::toTuple);
private final JedisClusterConnection connection;
@@ -142,7 +144,7 @@ public Tuple zRandMemberWithScore(byte[] key) {
Assert.notNull(key, "Key must not be null!");
try {
- Set tuples = connection.getCluster().zrandmemberWithScores(key, 1);
+ List tuples = connection.getCluster().zrandmemberWithScores(key, 1);
return tuples.isEmpty() ? null : JedisConverters.toTuple(tuples.iterator().next());
} catch (Exception ex) {
@@ -156,7 +158,7 @@ public List zRandMemberWithScore(byte[] key, long count) {
Assert.notNull(key, "Key must not be null!");
try {
- Set tuples = connection.getCluster().zrandmemberWithScores(key, count);
+ List tuples = connection.getCluster().zrandmemberWithScores(key, count);
return tuples.stream().map(JedisConverters::toTuple).collect(Collectors.toList());
} catch (Exception ex) {
@@ -196,7 +198,7 @@ public Set zRange(byte[] key, long start, long end) {
Assert.notNull(key, "Key must not be null!");
try {
- return connection.getCluster().zrange(key, start, end);
+ return new LinkedHashSet<>(connection.getCluster().zrange(key, start, end));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -234,9 +236,10 @@ public Set zRevRangeByScore(byte[] key, Range range, org.springframework
try {
if (limit.isUnlimited()) {
- return connection.getCluster().zrevrangeByScore(key, max, min);
+ return new LinkedHashSet<>(connection.getCluster().zrevrangeByScore(key, max, min));
}
- return connection.getCluster().zrevrangeByScore(key, max, min, limit.getOffset(), limit.getCount());
+ return new LinkedHashSet<>(
+ connection.getCluster().zrevrangeByScore(key, max, min, limit.getOffset(), limit.getCount()));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -302,7 +305,7 @@ public Tuple zPopMin(byte[] key) {
Assert.notNull(key, "Key must not be null!");
try {
- redis.clients.jedis.Tuple tuple = connection.getCluster().zpopmin(key);
+ redis.clients.jedis.resps.Tuple tuple = connection.getCluster().zpopmin(key);
return tuple != null ? JedisConverters.toTuple(tuple) : null;
} catch (Exception ex) {
throw convertJedisAccessException(ex);
@@ -343,7 +346,7 @@ public Tuple zPopMax(byte[] key) {
Assert.notNull(key, "Key must not be null!");
try {
- redis.clients.jedis.Tuple tuple = connection.getCluster().zpopmax(key);
+ redis.clients.jedis.resps.Tuple tuple = connection.getCluster().zpopmax(key);
return tuple != null ? JedisConverters.toTuple(tuple) : null;
} catch (Exception ex) {
throw convertJedisAccessException(ex);
@@ -405,9 +408,10 @@ public Set zRangeByScore(byte[] key, Range range, org.springframework.da
try {
if (limit.isUnlimited()) {
- return connection.getCluster().zrangeByScore(key, min, max);
+ return new LinkedHashSet<>(connection.getCluster().zrangeByScore(key, min, max));
}
- return connection.getCluster().zrangeByScore(key, min, max, limit.getOffset(), limit.getCount());
+ return new LinkedHashSet<>(
+ connection.getCluster().zrangeByScore(key, min, max, limit.getOffset(), limit.getCount()));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -425,9 +429,10 @@ public Set zRangeByLex(byte[] key, Range range, org.springframework.data
try {
if (limit.isUnlimited()) {
- return connection.getCluster().zrangeByLex(key, min, max);
+ return new LinkedHashSet<>(connection.getCluster().zrangeByLex(key, min, max));
}
- return connection.getCluster().zrangeByLex(key, min, max, limit.getOffset(), limit.getCount());
+ return new LinkedHashSet<>(
+ connection.getCluster().zrangeByLex(key, min, max, limit.getOffset(), limit.getCount()));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -461,9 +466,10 @@ public Set zRevRangeByLex(byte[] key, Range range, org.springframework.d
try {
if (limit.isUnlimited()) {
- return connection.getCluster().zrevrangeByLex(key, max, min);
+ return new LinkedHashSet<>(connection.getCluster().zrevrangeByLex(key, max, min));
}
- return connection.getCluster().zrevrangeByLex(key, max, min, limit.getOffset(), limit.getCount());
+ return new LinkedHashSet<>(
+ connection.getCluster().zrevrangeByLex(key, max, min, limit.getOffset(), limit.getCount()));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -487,7 +493,7 @@ public Set zRangeByScore(byte[] key, double min, double max) {
Assert.notNull(key, "Key must not be null!");
try {
- return connection.getCluster().zrangeByScore(key, min, max);
+ return new LinkedHashSet<>(connection.getCluster().zrangeByScore(key, min, max));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -515,8 +521,8 @@ public Set zRangeByScore(byte[] key, double min, double max, long offset
}
try {
- return connection.getCluster().zrangeByScore(key, min, max, Long.valueOf(offset).intValue(),
- Long.valueOf(count).intValue());
+ return new LinkedHashSet<>(connection.getCluster().zrangeByScore(key, min, max, Long.valueOf(offset).intValue(),
+ Long.valueOf(count).intValue()));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -545,7 +551,7 @@ public Set zRevRange(byte[] key, long start, long end) {
Assert.notNull(key, "Key must not be null!");
try {
- return connection.getCluster().zrevrange(key, start, end);
+ return new LinkedHashSet<>(connection.getCluster().zrevrange(key, start, end));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -569,7 +575,7 @@ public Set zRevRangeByScore(byte[] key, double min, double max) {
Assert.notNull(key, "Key must not be null!");
try {
- return connection.getCluster().zrevrangeByScore(key, max, min);
+ return new LinkedHashSet<>(connection.getCluster().zrevrangeByScore(key, max, min));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -597,8 +603,8 @@ public Set zRevRangeByScore(byte[] key, double min, double max, long off
}
try {
- return connection.getCluster().zrevrangeByScore(key, max, min, Long.valueOf(offset).intValue(),
- Long.valueOf(count).intValue());
+ return new LinkedHashSet<>(connection.getCluster().zrevrangeByScore(key, max, min,
+ Long.valueOf(offset).intValue(), Long.valueOf(count).intValue()));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -961,7 +967,7 @@ protected ScanIteration doScan(long cursorId, ScanOptions options) {
ScanParams params = JedisConverters.toScanParams(options);
- redis.clients.jedis.ScanResult result = connection.getCluster().zscan(key,
+ ScanResult result = connection.getCluster().zscan(key,
JedisConverters.toBytes(cursorId), params);
return new ScanIteration<>(Long.valueOf(result.getCursor()),
JedisConverters.tuplesToTuples().convert(result.getResult()));
@@ -975,7 +981,8 @@ public Set zRangeByScore(byte[] key, String min, String max) {
Assert.notNull(key, "Key must not be null!");
try {
- return connection.getCluster().zrangeByScore(key, JedisConverters.toBytes(min), JedisConverters.toBytes(max));
+ return new LinkedHashSet<>(
+ connection.getCluster().zrangeByScore(key, JedisConverters.toBytes(min), JedisConverters.toBytes(max)));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -991,8 +998,8 @@ public Set zRangeByScore(byte[] key, String min, String max, long offset
}
try {
- return connection.getCluster().zrangeByScore(key, JedisConverters.toBytes(min), JedisConverters.toBytes(max),
- Long.valueOf(offset).intValue(), Long.valueOf(count).intValue());
+ return new LinkedHashSet<>(connection.getCluster().zrangeByScore(key, JedisConverters.toBytes(min),
+ JedisConverters.toBytes(max), Long.valueOf(offset).intValue(), Long.valueOf(count).intValue()));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -1002,7 +1009,7 @@ private DataAccessException convertJedisAccessException(Exception ex) {
return connection.convertJedisAccessException(ex);
}
- private static Set toTupleSet(Set source) {
+ private static Set toTupleSet(List source) {
return TUPLE_SET_CONVERTER.convert(source);
}
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java
index de9a22de0f..ffcf5200c1 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java
@@ -15,7 +15,18 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.*;
+import redis.clients.jedis.BuilderFactory;
+import redis.clients.jedis.CommandArguments;
+import redis.clients.jedis.CommandObject;
+import redis.clients.jedis.DefaultJedisClientConfig;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisClientConfig;
+import redis.clients.jedis.Pipeline;
+import redis.clients.jedis.Response;
+import redis.clients.jedis.Transaction;
+import redis.clients.jedis.commands.ProtocolCommand;
+import redis.clients.jedis.commands.ServerCommands;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.util.Pool;
@@ -36,6 +47,7 @@
import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.*;
import org.springframework.data.redis.connection.convert.TransactionResultConverter;
+import org.springframework.data.redis.connection.jedis.JedisInvoker.ResponseCommands;
import org.springframework.data.redis.connection.jedis.JedisResult.JedisResultBuilder;
import org.springframework.data.redis.connection.jedis.JedisResult.JedisStatusResult;
import org.springframework.lang.Nullable;
@@ -43,7 +55,7 @@
import org.springframework.util.CollectionUtils;
/**
- * {@code RedisConnection} implementation on top of Jedis library.
+ * {@code RedisConnection} implementation on top of Jedis library.
*
* @author Costin Leau
* @author Jennifer Hickey
@@ -83,11 +95,8 @@ public class JedisConnection extends AbstractRedisConnection {
private final JedisZSetCommands zSetCommands = new JedisZSetCommands(this);
private final @Nullable Pool pool;
- private final String clientName;
- private final JedisClientConfig nodeConfig;
private final JedisClientConfig sentinelConfig;
-
private List pipelinedResults = new ArrayList<>();
private Queue>> txResults = new LinkedList<>();
@@ -148,8 +157,6 @@ protected JedisConnection(Jedis jedis, @Nullable Pool pool, JedisClientCo
this.jedis = jedis;
this.pool = pool;
- this.clientName = nodeConfig.getClientName();
- this.nodeConfig = nodeConfig;
this.sentinelConfig = sentinelConfig;
// select the db
@@ -167,22 +174,22 @@ protected JedisConnection(Jedis jedis, @Nullable Pool pool, JedisClientCo
@Nullable
private Object doInvoke(boolean status, Function directFunction,
- Function> pipelineFunction, Converter converter,
+ Function> pipelineFunction, Converter converter,
Supplier nullDefault) {
return doWithJedis(it -> {
- if (isPipelined()) {
+ if (isQueueing()) {
- Response response = pipelineFunction.apply(getRequiredPipeline());
- pipeline(status ? newStatusResult(response) : newJedisResult(response, converter, nullDefault));
+ Response response = pipelineFunction.apply(JedisInvoker.createCommands(getRequiredTransaction()));
+ transaction(status ? newStatusResult(response) : newJedisResult(response, converter, nullDefault));
return null;
}
- if (isQueueing()) {
+ if (isPipelined()) {
- Response response = pipelineFunction.apply(getRequiredTransaction());
- transaction(status ? newStatusResult(response) : newJedisResult(response, converter, nullDefault));
+ Response response = pipelineFunction.apply(JedisInvoker.createCommands(getRequiredPipeline()));
+ pipeline(status ? newStatusResult(response) : newJedisResult(response, converter, nullDefault));
return null;
}
@@ -263,32 +270,27 @@ public RedisServerCommands serverCommands() {
@Override
public Object execute(String command, byte[]... args) {
- return execute(command, args, Connection::getOne, JedisClientUtils::getResponse);
- }
-
- @Nullable
- T execute(String command, byte[][] args, Function resultMapper,
- Function> pipelineResponseMapper) {
Assert.hasText(command, "A valid command needs to be specified!");
Assert.notNull(args, "Arguments must not be null!");
return doWithJedis(it -> {
- Client client = JedisClientUtils.sendCommand(command, args, it);
+ ProtocolCommand protocolCommand = () -> JedisConverters.toBytes(command);
if (isQueueing() || isPipelined()) {
- Response> result = pipelineResponseMapper
- .apply(isPipelined() ? getRequiredPipeline() : getRequiredTransaction());
+ CommandArguments arguments = new CommandArguments(protocolCommand).addObjects(args);
+ CommandObject commandObject = new CommandObject<>(arguments, BuilderFactory.RAW_OBJECT);
if (isPipelined()) {
- pipeline(newJedisResult(result));
+ pipeline(newJedisResult(getRequiredPipeline().executeCommand(commandObject)));
} else {
- transaction(newJedisResult(result));
+ transaction(newJedisResult(getRequiredTransaction().executeCommand(commandObject)));
}
return null;
}
- return resultMapper.apply(client);
+
+ return it.sendCommand(protocolCommand, args);
});
}
@@ -330,16 +332,21 @@ public boolean isClosed() {
@Override
public boolean isQueueing() {
- return JedisClientUtils.isInMulti(jedis);
+ return transaction != null;
}
@Override
public boolean isPipelined() {
- return (pipeline != null);
+ return pipeline != null;
}
@Override
public void openPipeline() {
+
+ if (isQueueing()) {
+ throw new InvalidDataAccessApiUsageException("Cannot use Pipelining while a transaction is active");
+ }
+
if (pipeline == null) {
pipeline = jedis.pipelined();
}
@@ -406,21 +413,17 @@ public byte[] echo(byte[] message) {
Assert.notNull(message, "Message must not be null");
- return invoke().just(BinaryJedis::echo, MultiKeyPipelineBase::echo, message);
+ return invoke().just(j -> j.echo(message));
}
@Override
public String ping() {
- return invoke().just(BinaryJedis::ping, MultiKeyPipelineBase::ping);
+ return invoke().just(ServerCommands::ping);
}
@Override
public void discard() {
try {
- if (isPipelined()) {
- pipeline(newStatusResult(getRequiredPipeline().discard()));
- return;
- }
getRequiredTransaction().discard();
} catch (Exception ex) {
throw convertJedisAccessException(ex);
@@ -433,11 +436,6 @@ public void discard() {
@Override
public List exec() {
try {
- if (isPipelined()) {
- pipeline(newJedisResult(getRequiredPipeline().exec(),
- new TransactionResultConverter<>(new LinkedList<>(txResults), JedisExceptionConverter.INSTANCE)));
- return null;
- }
if (transaction == null) {
throw new InvalidDataAccessApiUsageException("No ongoing transaction. Did you forget to call multi?");
@@ -517,12 +515,6 @@ JedisResult newJedisResult(Response response) {
return JedisResultBuilder. forResponse(response).build();
}
- JedisResult newJedisResult(Response response, Converter converter) {
-
- return JedisResultBuilder. forResponse(response).mappedWith(converter)
- .convertPipelineAndTxResults(convertPipelineAndTxResults).build();
- }
-
JedisResult newJedisResult(Response response, Converter converter, Supplier defaultValue) {
return JedisResultBuilder. forResponse(response).mappedWith(converter)
@@ -539,39 +531,34 @@ public void multi() {
return;
}
- doWithJedis(it -> {
+ if (isPipelined()) {
+ throw new InvalidDataAccessApiUsageException("Cannot use Transaction while a pipeline is open");
+ }
- if (isPipelined()) {
- getRequiredPipeline().multi();
- return;
- }
+ doWithJedis(it -> {
this.transaction = it.multi();
});
}
@Override
public void select(int dbIndex) {
- invokeStatus().just(BinaryJedis::select, MultiKeyPipelineBase::select, dbIndex);
+ getJedis().select(dbIndex);
}
@Override
public void unwatch() {
- doWithJedis((Consumer) BinaryJedis::unwatch);
+ doWithJedis((Consumer) Jedis::unwatch);
}
@Override
public void watch(byte[]... keys) {
if (isQueueing()) {
- throw new UnsupportedOperationException();
+ throw new InvalidDataAccessApiUsageException("WATCH is not supported when a transaction is active");
}
doWithJedis(it -> {
for (byte[] key : keys) {
- if (isPipelined()) {
- pipeline(newStatusResult(getRequiredPipeline().watch(key)));
- } else {
- it.watch(key);
- }
+ it.watch(key);
}
});
}
@@ -582,7 +569,7 @@ public void watch(byte[]... keys) {
@Override
public Long publish(byte[] channel, byte[] message) {
- return invoke().just(BinaryJedis::publish, MultiKeyPipelineBase::publish, channel, message);
+ return invoke().just(j -> j.publish(channel, message));
}
@Override
@@ -604,7 +591,7 @@ public void pSubscribe(MessageListener listener, byte[]... patterns) {
}
if (isQueueing() || isPipelined()) {
- throw new UnsupportedOperationException();
+ throw new InvalidDataAccessApiUsageException("Cannot subscribe in pipeline / transaction mode");
}
doWithJedis(it -> {
@@ -625,7 +612,7 @@ public void subscribe(MessageListener listener, byte[]... channels) {
}
if (isQueueing() || isPipelined()) {
- throw new UnsupportedOperationException();
+ throw new InvalidDataAccessApiUsageException("Cannot subscribe in pipeline / transaction mode");
}
doWithJedis(it -> {
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnectionFactory.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnectionFactory.java
index c1d751e8d9..93ddc1c785 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnectionFactory.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnectionFactory.java
@@ -15,6 +15,7 @@
*/
package org.springframework.data.redis.connection.jedis;
+import redis.clients.jedis.Connection;
import redis.clients.jedis.DefaultJedisClientConfig;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
@@ -23,7 +24,6 @@
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;
-import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.util.Pool;
@@ -108,8 +108,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
private boolean destroyed;
/**
- * Constructs a new JedisConnectionFactory
instance with default settings (default connection pooling, no
- * shard information).
+ * Constructs a new {@link JedisConnectionFactory} instance with default settings (default connection pooling).
*/
public JedisConnectionFactory() {
this(new MutableJedisClientConfiguration());
@@ -129,7 +128,7 @@ private JedisConnectionFactory(JedisClientConfiguration clientConfig) {
}
/**
- * Constructs a new JedisConnectionFactory
instance using the given pool configuration.
+ * Constructs a new {@link JedisConnectionFactory} instance using the given pool configuration.
*
* @param poolConfig pool configuration
*/
@@ -274,7 +273,6 @@ protected Jedis fetchJedisConnector() {
}
private Jedis createJedis() {
-
return new Jedis(new HostAndPort(getHostName(), getPort()), this.clientConfig);
}
@@ -401,7 +399,7 @@ protected ClusterTopologyProvider createTopologyProvider(JedisCluster cluster) {
* @since 1.7
*/
protected JedisCluster createCluster(RedisClusterConfiguration clusterConfig,
- GenericObjectPoolConfig poolConfig) {
+ GenericObjectPoolConfig poolConfig) {
Assert.notNull(clusterConfig, "Cluster configuration must not be null!");
@@ -649,7 +647,7 @@ public void setUsePool(boolean usePool) {
* @return the poolConfig
*/
@Nullable
- public GenericObjectPoolConfig getPoolConfig() {
+ public GenericObjectPoolConfig getPoolConfig() {
return clientConfiguration.getPoolConfig().orElse(null);
}
@@ -835,7 +833,6 @@ private Jedis getActiveSentinel() {
throw new InvalidDataAccessResourceUsageException("No Sentinel found");
}
-
private static Set convertToJedisSentinelSet(Collection nodes) {
if (CollectionUtils.isEmpty(nodes)) {
@@ -890,12 +887,6 @@ static class MutableJedisClientConfiguration implements JedisClientConfiguration
private Duration readTimeout = Duration.ofMillis(Protocol.DEFAULT_TIMEOUT);
private Duration connectTimeout = Duration.ofMillis(Protocol.DEFAULT_TIMEOUT);
- public static JedisClientConfiguration create(JedisShardInfo shardInfo) {
-
- MutableJedisClientConfiguration configuration = new MutableJedisClientConfiguration();
- return configuration;
- }
-
public static JedisClientConfiguration create(GenericObjectPoolConfig jedisPoolConfig) {
MutableJedisClientConfiguration configuration = new MutableJedisClientConfiguration();
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java
index fa10a250f3..8b72d3fd06 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java
@@ -15,25 +15,25 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.BitOP;
import redis.clients.jedis.GeoCoordinate;
-import redis.clients.jedis.GeoRadiusResponse;
-import redis.clients.jedis.GeoUnit;
-import redis.clients.jedis.ListPosition;
-import redis.clients.jedis.ScanParams;
-import redis.clients.jedis.SortingParams;
+import redis.clients.jedis.args.BitOP;
import redis.clients.jedis.args.FlushMode;
+import redis.clients.jedis.args.GeoUnit;
+import redis.clients.jedis.args.ListPosition;
import redis.clients.jedis.params.GeoRadiusParam;
+import redis.clients.jedis.params.GeoSearchParam;
import redis.clients.jedis.params.GetExParams;
+import redis.clients.jedis.params.ScanParams;
import redis.clients.jedis.params.SetParams;
+import redis.clients.jedis.params.SortingParams;
import redis.clients.jedis.params.ZAddParams;
+import redis.clients.jedis.resps.GeoRadiusResponse;
import redis.clients.jedis.util.SafeEncoder;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -41,6 +41,7 @@
import java.util.concurrent.TimeUnit;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.data.domain.Sort;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.GeoResult;
import org.springframework.data.geo.GeoResults;
@@ -52,6 +53,7 @@
import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldSet;
import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldSubCommand;
import org.springframework.data.redis.connection.RedisClusterNode;
+import org.springframework.data.redis.connection.RedisGeoCommands;
import org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit;
import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation;
import org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs;
@@ -76,6 +78,11 @@
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.types.Expiration;
import org.springframework.data.redis.core.types.RedisClientInfo;
+import org.springframework.data.redis.domain.geo.BoundingBox;
+import org.springframework.data.redis.domain.geo.BoxShape;
+import org.springframework.data.redis.domain.geo.GeoReference;
+import org.springframework.data.redis.domain.geo.GeoShape;
+import org.springframework.data.redis.domain.geo.RadiusShape;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -94,7 +101,7 @@
* @author dengliming
*/
@SuppressWarnings("ConstantConditions")
-public abstract class JedisConverters extends Converters {
+abstract class JedisConverters extends Converters {
public static final byte[] PLUS_BYTES;
public static final byte[] MINUS_BYTES;
@@ -114,12 +121,12 @@ public static Converter stringToBytes() {
}
/**
- * {@link ListConverter} converting jedis {@link redis.clients.jedis.Tuple} to {@link Tuple}.
+ * {@link ListConverter} converting jedis {@link redis.clients.jedis.resps.Tuple} to {@link Tuple}.
*
* @return
* @since 1.4
*/
- static ListConverter tuplesToTuples() {
+ static ListConverter tuplesToTuples() {
return new ListConverter<>(JedisConverters::toTuple);
}
@@ -127,14 +134,11 @@ static ListConverter stringListToByteList() {
return new ListConverter<>(stringToBytes());
}
- /**
- * @deprecated since 2.5
- */
- static Set toTupleSet(Set source) {
+ static Set toTupleSet(Set source) {
return new SetConverter<>(JedisConverters::toTuple).convert(source);
}
- public static Tuple toTuple(redis.clients.jedis.Tuple source) {
+ public static Tuple toTuple(redis.clients.jedis.resps.Tuple source) {
return new DefaultTuple(source.getBinaryElement(), source.getScore());
}
@@ -150,10 +154,8 @@ public static Map toTupleMap(Set tuples) {
Assert.notNull(tuples, "Tuple set must not be null!");
Map args = new LinkedHashMap<>(tuples.size(), 1);
- Set scores = new HashSet<>(tuples.size(), 1);
for (Tuple tuple : tuples) {
- scores.add(tuple.getScore());
args.put(tuple.getValue(), tuple.getScore());
}
@@ -238,7 +240,6 @@ public static List toListOfRedisClientInformation(String source
* @since 1.4
*/
public static List toListOfRedisServer(List> source) {
-
return toList(it -> RedisServer.newServerFrom(Converters.toProperties(it)), source);
}
@@ -586,7 +587,7 @@ public static GeoCoordinate toGeoCoordinate(Point source) {
* @return
* @since 1.8
*/
- public static Converter, GeoResults>> geoRadiusResponseToGeoResultsConverter(
+ public static Converter, GeoResults>> geoRadiusResponseToGeoResultsConverter(
Metric metric) {
return GeoResultsConverterFactory.INSTANCE.forMetric(metric);
}
@@ -759,6 +760,86 @@ static FlushMode toFlushMode(@Nullable RedisServerCommands.FlushOption option) {
}
}
+ static GeoSearchParam toGeoSearchParams(GeoReference reference, GeoShape predicate,
+ RedisGeoCommands.GeoCommandArgs args) {
+
+ Assert.notNull(reference, "GeoReference must not be null!");
+ Assert.notNull(predicate, "GeoShape must not be null!");
+ Assert.notNull(args, "GeoSearchCommandArgs must not be null!");
+
+ GeoSearchParam param = GeoSearchParam.geoSearchParam();
+
+ configureGeoReference(reference, param);
+
+ if (args.getLimit() != null) {
+
+ boolean hasAnyLimit = args.getFlags().contains(Flag.ANY);
+ param.count(Math.toIntExact(args.getLimit()), hasAnyLimit);
+ }
+
+ if (args.getSortDirection() != null) {
+
+ if (args.getSortDirection() == Sort.Direction.ASC) {
+ param.asc();
+ } else {
+ param.desc();
+ }
+ }
+
+ if (args.getFlags().contains(Flag.WITHDIST)) {
+ param.withDist();
+ }
+
+ if (args.getFlags().contains(Flag.WITHCOORD)) {
+ param.withCoord();
+ }
+
+ return getGeoSearchParam(predicate, param);
+ }
+
+ private static GeoSearchParam getGeoSearchParam(GeoShape predicate, GeoSearchParam param) {
+
+ if (predicate instanceof RadiusShape) {
+
+ Distance radius = ((RadiusShape) predicate).getRadius();
+
+ param.byRadius(radius.getValue(), toGeoUnit(radius.getMetric()));
+
+ return param;
+ }
+
+ if (predicate instanceof BoxShape) {
+
+ BoxShape boxPredicate = (BoxShape) predicate;
+ BoundingBox boundingBox = boxPredicate.getBoundingBox();
+
+ param.byBox(boundingBox.getWidth().getValue(), boundingBox.getHeight().getValue(),
+ toGeoUnit(boxPredicate.getMetric()));
+
+ return param;
+ }
+
+ throw new IllegalArgumentException(String.format("Cannot convert %s to Jedis GeoSearchParam", predicate));
+ }
+
+ private static void configureGeoReference(GeoReference reference, GeoSearchParam param) {
+
+ if (reference instanceof GeoReference.GeoMemberReference) {
+
+ param.fromMember(toString(((GeoReference.GeoMemberReference) reference).getMember()));
+ return;
+ }
+
+ if (reference instanceof GeoReference.GeoCoordinateReference) {
+
+ GeoReference.GeoCoordinateReference> coordinates = (GeoReference.GeoCoordinateReference>) reference;
+ param.fromLonLat(coordinates.getLongitude(), coordinates.getLatitude());
+ return;
+ }
+
+ throw new IllegalArgumentException(String.format("Cannot extract Geo Reference from %s", reference));
+ }
+
/**
* @author Christoph Strobl
* @since 1.8
@@ -767,13 +848,13 @@ enum GeoResultsConverterFactory {
INSTANCE;
- Converter, GeoResults>> forMetric(Metric metric) {
+ Converter, GeoResults>> forMetric(Metric metric) {
return new GeoResultsConverter(
ObjectUtils.nullSafeEquals(Metrics.NEUTRAL, metric) ? DistanceUnit.METERS : metric);
}
private static class GeoResultsConverter
- implements Converter, GeoResults>> {
+ implements Converter, GeoResults>> {
private final Metric metric;
@@ -786,7 +867,7 @@ public GeoResults> convert(List source) {
List>> results = new ArrayList<>(source.size());
- Converter>> converter = GeoResultConverterFactory.INSTANCE
+ Converter>> converter = GeoResultConverterFactory.INSTANCE
.forMetric(metric);
for (GeoRadiusResponse result : source) {
results.add(converter.convert(result));
@@ -805,12 +886,11 @@ enum GeoResultConverterFactory {
INSTANCE;
- Converter>> forMetric(Metric metric) {
+ Converter>> forMetric(Metric metric) {
return new GeoResultConverter(metric);
}
- private static class GeoResultConverter
- implements Converter>> {
+ private static class GeoResultConverter implements Converter>> {
private final Metric metric;
@@ -819,7 +899,7 @@ public GeoResultConverter(Metric metric) {
}
@Override
- public GeoResult> convert(redis.clients.jedis.GeoRadiusResponse source) {
+ public GeoResult> convert(GeoRadiusResponse source) {
Point point = JedisConverters.toPoint(source.getCoordinate());
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisExceptionConverter.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisExceptionConverter.java
index 278793faf3..b3c34969f9 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisExceptionConverter.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisExceptionConverter.java
@@ -15,7 +15,7 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.exceptions.JedisClusterMaxAttemptsException;
+import redis.clients.jedis.exceptions.JedisClusterOperationException;
import redis.clients.jedis.exceptions.JedisConnectionException;
import redis.clients.jedis.exceptions.JedisException;
import redis.clients.jedis.exceptions.JedisRedirectionException;
@@ -49,7 +49,11 @@ public DataAccessException convert(Exception ex) {
return (DataAccessException) ex;
}
- if (ex instanceof JedisClusterMaxAttemptsException) {
+ if (ex instanceof UnsupportedOperationException) {
+ return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
+ }
+
+ if (ex instanceof JedisClusterOperationException && "No more cluster attempts left.".equals(ex.getMessage())) {
return new TooManyClusterRedirectionsException(ex.getMessage(), ex);
}
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisGeoCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisGeoCommands.java
index 6c232eb386..1efc1fd329 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisGeoCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisGeoCommands.java
@@ -15,12 +15,11 @@
*/
package org.springframework.data.redis.connection.jedis;
-import org.springframework.data.redis.domain.geo.GeoReference;
-import org.springframework.data.redis.domain.geo.GeoShape;
-import redis.clients.jedis.BinaryJedis;
import redis.clients.jedis.GeoCoordinate;
-import redis.clients.jedis.GeoUnit;
-import redis.clients.jedis.MultiKeyPipelineBase;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.args.GeoUnit;
+import redis.clients.jedis.commands.PipelineBinaryCommands;
+import redis.clients.jedis.params.GeoSearchParam;
import java.util.HashMap;
import java.util.List;
@@ -33,6 +32,8 @@
import org.springframework.data.geo.Metric;
import org.springframework.data.geo.Point;
import org.springframework.data.redis.connection.RedisGeoCommands;
+import org.springframework.data.redis.domain.geo.GeoReference;
+import org.springframework.data.redis.domain.geo.GeoShape;
import org.springframework.util.Assert;
/**
@@ -55,7 +56,7 @@ public Long geoAdd(byte[] key, Point point, byte[] member) {
Assert.notNull(point, "Point must not be null!");
Assert.notNull(member, "Member must not be null!");
- return connection.invoke().just(BinaryJedis::geoadd, MultiKeyPipelineBase::geoadd, key, point.getX(), point.getY(),
+ return connection.invoke().just(Jedis::geoadd, PipelineBinaryCommands::geoadd, key, point.getX(), point.getY(),
member);
}
@@ -71,7 +72,7 @@ public Long geoAdd(byte[] key, Map memberCoordinateMap) {
redisGeoCoordinateMap.put(mapKey, JedisConverters.toGeoCoordinate(memberCoordinateMap.get(mapKey)));
}
- return connection.invoke().just(BinaryJedis::geoadd, MultiKeyPipelineBase::geoadd, key, redisGeoCoordinateMap);
+ return connection.invoke().just(Jedis::geoadd, PipelineBinaryCommands::geoadd, key, redisGeoCoordinateMap);
}
@Override
@@ -86,7 +87,7 @@ public Long geoAdd(byte[] key, Iterable> locations) {
redisGeoCoordinateMap.put(location.getName(), JedisConverters.toGeoCoordinate(location.getPoint()));
}
- return connection.invoke().just(BinaryJedis::geoadd, MultiKeyPipelineBase::geoadd, key, redisGeoCoordinateMap);
+ return connection.invoke().just(Jedis::geoadd, PipelineBinaryCommands::geoadd, key, redisGeoCoordinateMap);
}
@Override
@@ -98,7 +99,7 @@ public Distance geoDist(byte[] key, byte[] member1, byte[] member2) {
Converter distanceConverter = JedisConverters.distanceConverterForMetric(DistanceUnit.METERS);
- return connection.invoke().from(BinaryJedis::geodist, MultiKeyPipelineBase::geodist, key, member1, member2)
+ return connection.invoke().from(Jedis::geodist, PipelineBinaryCommands::geodist, key, member1, member2)
.get(distanceConverter);
}
@@ -113,7 +114,7 @@ public Distance geoDist(byte[] key, byte[] member1, byte[] member2, Metric metri
GeoUnit geoUnit = JedisConverters.toGeoUnit(metric);
Converter distanceConverter = JedisConverters.distanceConverterForMetric(metric);
- return connection.invoke().from(BinaryJedis::geodist, MultiKeyPipelineBase::geodist, key, member1, member2, geoUnit)
+ return connection.invoke().from(Jedis::geodist, PipelineBinaryCommands::geodist, key, member1, member2, geoUnit)
.get(distanceConverter);
}
@@ -124,7 +125,7 @@ public List geoHash(byte[] key, byte[]... members) {
Assert.notNull(members, "Members must not be null!");
Assert.noNullElements(members, "Members must not contain null!");
- return connection.invoke().fromMany(BinaryJedis::geohash, MultiKeyPipelineBase::geohash, key, members)
+ return connection.invoke().fromMany(Jedis::geohash, PipelineBinaryCommands::geohash, key, members)
.toList(JedisConverters::toString);
}
@@ -135,7 +136,7 @@ public List geoPos(byte[] key, byte[]... members) {
Assert.notNull(members, "Members must not be null!");
Assert.noNullElements(members, "Members must not contain null!");
- return connection.invoke().fromMany(BinaryJedis::geopos, MultiKeyPipelineBase::geopos, key, members)
+ return connection.invoke().fromMany(Jedis::geopos, PipelineBinaryCommands::geopos, key, members)
.toList(JedisConverters::toPoint);
}
@@ -145,11 +146,11 @@ public GeoResults> geoRadius(byte[] key, Circle within) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(within, "Within must not be null!");
- Converter, GeoResults>> converter = JedisConverters
+ Converter, GeoResults>> converter = JedisConverters
.geoRadiusResponseToGeoResultsConverter(within.getRadius().getMetric());
return connection.invoke()
- .from(BinaryJedis::georadius, MultiKeyPipelineBase::georadius, key, within.getCenter().getX(),
+ .from(Jedis::georadius, PipelineBinaryCommands::georadius, key, within.getCenter().getX(),
within.getCenter().getY(), within.getRadius().getValue(),
JedisConverters.toGeoUnit(within.getRadius().getMetric()))
.get(converter);
@@ -163,11 +164,11 @@ public GeoResults> geoRadius(byte[] key, Circle within, GeoR
Assert.notNull(args, "Args must not be null!");
redis.clients.jedis.params.GeoRadiusParam geoRadiusParam = JedisConverters.toGeoRadiusParam(args);
- Converter, GeoResults>> converter = JedisConverters
+ Converter, GeoResults>> converter = JedisConverters
.geoRadiusResponseToGeoResultsConverter(within.getRadius().getMetric());
- return connection.invoke().from(BinaryJedis::georadius, MultiKeyPipelineBase::georadius, key,
- within.getCenter().getX(),
+ return connection.invoke()
+ .from(Jedis::georadius, PipelineBinaryCommands::georadius, key, within.getCenter().getX(),
within.getCenter().getY(), within.getRadius().getValue(),
JedisConverters.toGeoUnit(within.getRadius().getMetric()), geoRadiusParam)
.get(converter);
@@ -181,11 +182,11 @@ public GeoResults> geoRadiusByMember(byte[] key, byte[] memb
Assert.notNull(radius, "Radius must not be null!");
GeoUnit geoUnit = JedisConverters.toGeoUnit(radius.getMetric());
- Converter, GeoResults>> converter = JedisConverters
+ Converter, GeoResults>> converter = JedisConverters
.geoRadiusResponseToGeoResultsConverter(radius.getMetric());
- return connection.invoke().from(BinaryJedis::georadiusByMember, MultiKeyPipelineBase::georadiusByMember, key,
- member, radius.getValue(), geoUnit).get(converter);
+ return connection.invoke().from(Jedis::georadiusByMember, PipelineBinaryCommands::georadiusByMember, key, member,
+ radius.getValue(), geoUnit).get(converter);
}
@Override
@@ -198,12 +199,12 @@ public GeoResults> geoRadiusByMember(byte[] key, byte[] memb
Assert.notNull(args, "Args must not be null!");
GeoUnit geoUnit = JedisConverters.toGeoUnit(radius.getMetric());
- Converter, GeoResults>> converter = JedisConverters
+ Converter, GeoResults>> converter = JedisConverters
.geoRadiusResponseToGeoResultsConverter(radius.getMetric());
redis.clients.jedis.params.GeoRadiusParam geoRadiusParam = JedisConverters.toGeoRadiusParam(args);
- return connection.invoke().from(BinaryJedis::georadiusByMember, MultiKeyPipelineBase::georadiusByMember, key,
- member, radius.getValue(), geoUnit, geoRadiusParam).get(converter);
+ return connection.invoke().from(Jedis::georadiusByMember, PipelineBinaryCommands::georadiusByMember, key, member,
+ radius.getValue(), geoUnit, geoRadiusParam).get(converter);
}
@Override
@@ -214,12 +215,30 @@ public Long geoRemove(byte[] key, byte[]... members) {
@Override
public GeoResults> geoSearch(byte[] key, GeoReference reference, GeoShape predicate,
GeoSearchCommandArgs args) {
- throw new UnsupportedOperationException("GEOSEARCH not supported through Jedis");
+
+ Assert.notNull(key, "Key must not be null!");
+
+ GeoSearchParam param = JedisConverters.toGeoSearchParams(reference, predicate, args);
+ Converter, GeoResults>> converter = JedisConverters
+ .geoRadiusResponseToGeoResultsConverter(predicate.getMetric());
+
+ return connection.invoke().from(Jedis::geosearch, PipelineBinaryCommands::geosearch, key, param).get(converter);
}
@Override
public Long geoSearchStore(byte[] destKey, byte[] key, GeoReference reference, GeoShape predicate,
GeoSearchStoreCommandArgs args) {
- throw new UnsupportedOperationException("GEOSEARCHSTORE not supported through Jedis");
+
+ Assert.notNull(destKey, "Destination Key must not be null!");
+ Assert.notNull(key, "Key must not be null!");
+
+ GeoSearchParam param = JedisConverters.toGeoSearchParams(reference, predicate, args);
+
+ if (args.isStoreDistance()) {
+ return connection.invoke().just(Jedis::geosearchStoreStoreDist, PipelineBinaryCommands::geosearchStoreStoreDist,
+ destKey, key, param);
+ }
+
+ return connection.invoke().just(Jedis::geosearchStore, PipelineBinaryCommands::geosearchStore, destKey, key, param);
}
}
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisHashCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisHashCommands.java
index 3da255e990..01310e1265 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisHashCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisHashCommands.java
@@ -15,10 +15,10 @@
*/
package org.springframework.data.redis.connection.jedis;
-import redis.clients.jedis.BinaryJedis;
-import redis.clients.jedis.MultiKeyPipelineBase;
-import redis.clients.jedis.ScanParams;
-import redis.clients.jedis.ScanResult;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.commands.PipelineBinaryCommands;
+import redis.clients.jedis.params.ScanParams;
+import redis.clients.jedis.resps.ScanResult;
import java.util.ArrayList;
import java.util.List;
@@ -26,6 +26,7 @@
import java.util.Map.Entry;
import java.util.Set;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.redis.connection.RedisHashCommands;
import org.springframework.data.redis.connection.convert.Converters;
import org.springframework.data.redis.core.Cursor;
@@ -55,7 +56,7 @@ public Boolean hSet(byte[] key, byte[] field, byte[] value) {
Assert.notNull(field, "Field must not be null!");
Assert.notNull(value, "Value must not be null!");
- return connection.invoke().from(BinaryJedis::hset, MultiKeyPipelineBase::hset, key, field, value)
+ return connection.invoke().from(Jedis::hset, PipelineBinaryCommands::hset, key, field, value)
.get(JedisConverters.longToBoolean());
}
@@ -66,7 +67,7 @@ public Boolean hSetNX(byte[] key, byte[] field, byte[] value) {
Assert.notNull(field, "Field must not be null!");
Assert.notNull(value, "Value must not be null!");
- return connection.invoke().from(BinaryJedis::hsetnx, MultiKeyPipelineBase::hsetnx, key, field, value)
+ return connection.invoke().from(Jedis::hsetnx, PipelineBinaryCommands::hsetnx, key, field, value)
.get(JedisConverters.longToBoolean());
}
@@ -76,7 +77,7 @@ public Long hDel(byte[] key, byte[]... fields) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(fields, "Fields must not be null!");
- return connection.invoke().just(BinaryJedis::hdel, MultiKeyPipelineBase::hdel, key, fields);
+ return connection.invoke().just(Jedis::hdel, PipelineBinaryCommands::hdel, key, fields);
}
@Override
@@ -85,7 +86,7 @@ public Boolean hExists(byte[] key, byte[] field) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(field, "Fields must not be null!");
- return connection.invoke().just(BinaryJedis::hexists, MultiKeyPipelineBase::hexists, key, field);
+ return connection.invoke().just(Jedis::hexists, PipelineBinaryCommands::hexists, key, field);
}
@Override
@@ -94,7 +95,7 @@ public byte[] hGet(byte[] key, byte[] field) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(field, "Field must not be null!");
- return connection.invoke().just(BinaryJedis::hget, MultiKeyPipelineBase::hget, key, field);
+ return connection.invoke().just(Jedis::hget, PipelineBinaryCommands::hget, key, field);
}
@Override
@@ -102,7 +103,7 @@ public Map hGetAll(byte[] key) {
Assert.notNull(key, "Key must not be null!");
- return connection.invoke().just(BinaryJedis::hgetAll, MultiKeyPipelineBase::hgetAll, key);
+ return connection.invoke().just(Jedis::hgetAll, PipelineBinaryCommands::hgetAll, key);
}
@Nullable
@@ -111,7 +112,7 @@ public byte[] hRandField(byte[] key) {
Assert.notNull(key, "Key must not be null!");
- return connection.invoke().just(BinaryJedis::hrandfield, MultiKeyPipelineBase::hrandfield, key);
+ return connection.invoke().just(Jedis::hrandfield, PipelineBinaryCommands::hrandfield, key);
}
@Nullable
@@ -120,8 +121,7 @@ public Entry hRandFieldWithValues(byte[] key) {
Assert.notNull(key, "Key must not be null!");
- return connection.invoke()
- .from(BinaryJedis::hrandfieldWithValues, MultiKeyPipelineBase::hrandfieldWithValues, key, 1L)
+ return connection.invoke().from(Jedis::hrandfieldWithValues, PipelineBinaryCommands::hrandfieldWithValues, key, 1L)
.get(it -> it.isEmpty() ? null : it.entrySet().iterator().next());
}
@@ -131,7 +131,7 @@ public List hRandField(byte[] key, long count) {
Assert.notNull(key, "Key must not be null!");
- return connection.invoke().just(BinaryJedis::hrandfield, MultiKeyPipelineBase::hrandfield, key, count);
+ return connection.invoke().just(Jedis::hrandfield, PipelineBinaryCommands::hrandfield, key, count);
}
@Nullable
@@ -141,7 +141,7 @@ public List> hRandFieldWithValues(byte[] key, long count)
Assert.notNull(key, "Key must not be null!");
return connection.invoke()
- .from(BinaryJedis::hrandfieldWithValues, MultiKeyPipelineBase::hrandfieldWithValues, key, count).get(it -> {
+ .from(Jedis::hrandfieldWithValues, PipelineBinaryCommands::hrandfieldWithValues, key, count).get(it -> {
List