diff --git a/src/main/asciidoc/reference/redis-transactions.adoc b/src/main/asciidoc/reference/redis-transactions.adoc index 2ab8cb3e2..f627bc5e1 100644 --- a/src/main/asciidoc/reference/redis-transactions.adoc +++ b/src/main/asciidoc/reference/redis-transactions.adoc @@ -1,7 +1,9 @@ [[tx]] = Redis Transactions -Redis provides support for https://redis.io/topics/transactions[transactions] through the `multi`, `exec`, and `discard` commands.These operations are available on `RedisTemplate`.However, `RedisTemplate` is not guaranteed to run all the operations in the transaction with the same connection. +Redis provides support for https://redis.io/topics/transactions[transactions] through the `multi`, `exec`, and `discard` commands. +These operations are available on `RedisTemplate`. +However, `RedisTemplate` is not guaranteed to run all the operations in the transaction with the same connection. Spring Data Redis provides the `SessionCallback` interface for use when multiple operations need to be performed with the same `connection`, such as when using Redis transactions.The following example uses the `multi` method: @@ -20,7 +22,8 @@ List txResults = redisTemplate.execute(new SessionCallback> System.out.println("Number of items added to set: " + txResults.get(0)); ---- -`RedisTemplate` uses its value, hash key, and hash value serializers to deserialize all results of `exec` before returning.There is an additional `exec` method that lets you pass a custom serializer for transaction results. +`RedisTemplate` uses its value, hash key, and hash value serializers to deserialize all results of `exec` before returning. +There is an additional `exec` method that lets you pass a custom serializer for transaction results. include::version-note.adoc[] @@ -74,7 +77,9 @@ public class RedisTxContextConfiguration { ---- <1> Configures a Spring Context to enable https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/data-access.html#transaction-declarative[declarative transaction management]. <2> Configures `RedisTemplate` to participate in transactions by binding connections to the current thread. -<3> Transaction management requires a `PlatformTransactionManager`.Spring Data Redis does not ship with a `PlatformTransactionManager` implementation.Assuming your application uses JDBC, Spring Data Redis can participate in transactions by using existing transaction managers. +<3> Transaction management requires a `PlatformTransactionManager`. +Spring Data Redis does not ship with a `PlatformTransactionManager` implementation. +Assuming your application uses JDBC, Spring Data Redis can participate in transactions by using existing transaction managers. ==== The following examples each demonstrate a usage constraint: diff --git a/src/main/java/org/springframework/data/redis/core/RedisConnectionUtils.java b/src/main/java/org/springframework/data/redis/core/RedisConnectionUtils.java index 379fe3f24..ed26ce74f 100644 --- a/src/main/java/org/springframework/data/redis/core/RedisConnectionUtils.java +++ b/src/main/java/org/springframework/data/redis/core/RedisConnectionUtils.java @@ -275,7 +275,7 @@ public abstract class RedisConnectionUtils { * @param factory the Redis factory that the connection was created with. * @param transactionSupport whether transaction support is enabled. * @since 2.1.9 - * @deprecated since 2.4.0, use {@link #releaseConnection(RedisConnection, RedisConnectionFactory)} + * @deprecated since 2.4.2, use {@link #releaseConnection(RedisConnection, RedisConnectionFactory)} */ @Deprecated public static void releaseConnection(@Nullable RedisConnection conn, RedisConnectionFactory factory, @@ -623,7 +623,7 @@ public abstract class RedisConnectionUtils { * Subinterface of {@link RedisConnection} to be implemented by {@link RedisConnection} proxies. Allows access to the * underlying target {@link RedisConnection}. * - * @since 2.4 + * @since 2.4.2 * @see RedisConnectionUtils#getTargetConnection(RedisConnection) */ interface RedisConnectionProxy extends RedisConnection, RawTargetAccess { diff --git a/src/test/java/org/springframework/data/redis/core/RedisTemplateUnitTests.java b/src/test/java/org/springframework/data/redis/core/RedisTemplateUnitTests.java index a05a1725e..491b290e2 100644 --- a/src/test/java/org/springframework/data/redis/core/RedisTemplateUnitTests.java +++ b/src/test/java/org/springframework/data/redis/core/RedisTemplateUnitTests.java @@ -136,7 +136,7 @@ class RedisTemplateUnitTests { verify(redisConnectionMock).close(); } - @Test // DATAREDIS-988 + @Test // DATAREDIS-988, DATAREDIS-891 void transactionAwareTemplateShouldReleaseConnection() { template.setEnableTransactionSupport(true);