Polishing.
Tweak wording around thread-safety. Include notices in connection factories. Reformat asciidoc. See #2653 Original pull request: #2667
This commit is contained in:
@@ -28,6 +28,9 @@ import org.springframework.util.Assert;
|
||||
* {@link RedisClusterNode} can be obtained from {@link #clusterGetNodes()} or it can be constructed using either
|
||||
* {@link RedisClusterNode#getHost() host} and {@link RedisClusterNode#getPort()} or the {@link RedisClusterNode#getId()
|
||||
* node Id}.
|
||||
* <p>
|
||||
* {@link RedisClusterConnection Redis connections}, unlike perhaps their underlying native connection are not
|
||||
* Thread-safe and should not be shared across multiple threads.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
|
||||
@@ -22,15 +22,14 @@ import org.springframework.dao.DataAccessException;
|
||||
/**
|
||||
* A connection to a Redis server.
|
||||
* <p>
|
||||
* The {@link RedisConnection} interface serves as a common abstraction across various Redis client libraries
|
||||
* (or drivers).
|
||||
* The {@link RedisConnection} interface serves as a common abstraction across various Redis client libraries (or
|
||||
* drivers).
|
||||
* <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.
|
||||
* {@link RedisConnection Redis connections}, unlike perhaps their underlying native connection are not Thread-safe and
|
||||
* should not be shared across multiple threads.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Christoph Strobl
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.PropertyAccessor;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@@ -61,6 +60,8 @@ import org.springframework.util.Assert;
|
||||
* {@link RedisClusterConnection} implementation on top of {@link JedisCluster}.<br/>
|
||||
* Uses the native {@link JedisCluster} api where possible and falls back to direct node communication using
|
||||
* {@link Jedis} where needed.
|
||||
* <p>
|
||||
* This class is not Thread-safe and instances should not be shared across threads.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.util.function.Supplier;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
@@ -60,10 +59,7 @@ 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.
|
||||
* This class is not Thread-safe and instances should not be shared across threads.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Jennifer Hickey
|
||||
|
||||
@@ -79,6 +79,11 @@ import org.springframework.util.ObjectUtils;
|
||||
* connection. {@link #afterPropertiesSet() Initialization} {@link SmartLifecycle#start() starts} this bean
|
||||
* {@link #isAutoStartup() by default}. You can {@link SmartLifecycle#stop()} and {@link SmartLifecycle#start() restart}
|
||||
* this connection factory if needed.
|
||||
* <p>
|
||||
* Note that {@link JedisConnection} and its {@link JedisClusterConnection clustered variant} are not Thread-safe and
|
||||
* instances should not be shared across threads. Refer to the
|
||||
* <a href="https://github.com/redis/jedis/wiki/Getting-started#using-jedis-in-a-multithreaded-environment">Jedis
|
||||
* documentation</a> for guidance on configuring Jedis in a multithreaded environment.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Thomas Darimont
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
@@ -53,6 +52,13 @@ import org.springframework.util.ObjectUtils;
|
||||
/**
|
||||
* {@code RedisClusterConnection} implementation on top of <a href="https://github.com/mp911de/lettuce">Lettuce</a>
|
||||
* Redis client.
|
||||
* <p>
|
||||
* While the underlying Lettuce {@literal RedisClient} and {@literal StatefulRedisConnection} instances used by
|
||||
* {@link LettuceClusterConnection} are Thread-safe, this class itself is not Thread-safe. Therefore, instances of
|
||||
* {@link LettuceClusterConnection} 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 Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
@@ -486,7 +492,6 @@ public class LettuceClusterConnection extends LettuceConnection
|
||||
throw new InvalidDataAccessApiUsageException("MULTI is currently not supported in cluster mode");
|
||||
}
|
||||
|
||||
|
||||
public ClusterCommandExecutor getClusterCommandExecutor() {
|
||||
return clusterCommandExecutor;
|
||||
}
|
||||
|
||||
@@ -80,12 +80,12 @@ 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.
|
||||
* 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
|
||||
|
||||
@@ -69,8 +69,10 @@ import org.springframework.util.StringUtils;
|
||||
/**
|
||||
* Connection factory creating <a href="https://github.com/mp911de/lettuce">Lettuce</a>-based connections.
|
||||
* <p>
|
||||
* This factory creates a new {@link LettuceConnection} on each call to {@link #getConnection()}. Multiple
|
||||
* {@link LettuceConnection}s share a single thread-safe native connection by default.
|
||||
* This factory creates a new {@link LettuceConnection} on each call to {@link #getConnection()}. While multiple
|
||||
* {@link LettuceConnection}s share a single thread-safe native connection by default, {@link LettuceConnection} and its
|
||||
* {@link LettuceClusterConnection clustered variant} are not Thread-safe and instances should not be shared across
|
||||
* threads.
|
||||
* <p>
|
||||
* The shared native connection is never closed by {@link LettuceConnection}, therefore it is not validated by default
|
||||
* on {@link #getConnection()}. Use {@link #setValidateConnection(boolean)} to change this behavior if necessary. If
|
||||
|
||||
Reference in New Issue
Block a user