Edit ref docs and Javadoc for connection classes to clearly state the Thread-safety guarantees.

Closes #2653
Original pull request: #2667
This commit is contained in:
John Blum
2023-08-08 15:03:44 -07:00
committed by Mark Paluch
parent d5642d9e4a
commit 4bf1d06758
4 changed files with 24 additions and 1 deletions

View File

@@ -27,6 +27,10 @@ import org.springframework.dao.DataAccessException;
* <p>
* 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.
* <p>
* 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

View File

@@ -59,6 +59,11 @@ import org.springframework.util.CollectionUtils;
/**
* {@code RedisConnection} implementation on top of <a href="https://github.com/redis/jedis">Jedis</a> library.
* <p>
* 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
* <a href="https://github.com/redis/jedis/wiki/Getting-started#using-jedis-in-a-multithreaded-environment">documented</a>
* as not Thread-safe.
*
* @author Costin Leau
* @author Jennifer Hickey
@@ -72,6 +77,8 @@ import org.springframework.util.CollectionUtils;
* @author Ninad Divadkar
* @author Guy Korland
* @author Dengliming
* @author John Blum
* @see redis.clients.jedis.Jedis
*/
public class JedisConnection extends AbstractRedisConnection {

View File

@@ -79,6 +79,13 @@ import org.springframework.util.ObjectUtils;
/**
* {@code RedisConnection} implementation on top of <a href="https://github.com/mp911de/lettuce">Lettuce</a> Redis
* client.
* <p>
* 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 @@ import org.springframework.util.ObjectUtils;
* @author Ninad Divadkar
* @author Tamil Selvan
* @author ihaohong
* @author John Blum
*/
public class LettuceConnection extends AbstractRedisConnection {