* Additionally, performs exception translation between the underlying Redis client library and Spring DAO exceptions. * The methods follow as much as possible the Redis names and conventions. + *
+ * Spring Data Redis {@link RedisConnection connections}, unlike perhaps their underlying native connection (for example: + * the Lettuce {@literal StatefulRedisConnection}) are not Thread-safe. Please refer to the corresponding the Javadoc + * for Redis client library (driver) specific connections provided by Spring Data Redis for more details. * * @author Costin Leau * @author Christoph Strobl 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 61231fd0b5..850210cd7d 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 @@ -59,6 +59,11 @@ /** * {@code RedisConnection} implementation on top of Jedis library. + *
+ * WARNING: The {@link JedisConnection} class is not Thread-safe. This class requires and uses a + * {@literal Jedis} instance from the Jedis client library (driver), which is very clearly + * documented + * as not Thread-safe. * * @author Costin Leau * @author Jennifer Hickey @@ -72,6 +77,8 @@ * @author Ninad Divadkar * @author Guy Korland * @author Dengliming + * @author John Blum + * @see redis.clients.jedis.Jedis */ public class JedisConnection extends AbstractRedisConnection { diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java index ddef4a1df6..f0ed270395 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java @@ -79,6 +79,13 @@ /** * {@code RedisConnection} implementation on top of Lettuce Redis * client. + *
+ * WARNING: While the underlying Lettuce {@literal RedisClient} and {@literal StatefulRedisConnection} instances used by + * {@link LettuceConnection} are Thread-safe, this class itself is not Thread-safe. Therefore, instances of {@link LettuceConnection} + * should not be shared across multiple Threads when executing Redis commands and other operations. If optimal performance + * is required by your application(s), then we recommend direct access to the low-level, API provided by the underlying + * Lettuce client library (driver), where such Thread-safety guarantees can be made. Simply call {@link #getNativeConnection()} + * and use the native resource as required. * * @author Costin Leau * @author Jennifer Hickey @@ -89,6 +96,7 @@ * @author Ninad Divadkar * @author Tamil Selvan * @author ihaohong + * @author John Blum */ public class LettuceConnection extends AbstractRedisConnection {