Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature Request: PlatformTransactionManager for Redis-only Applications #3205

Open
Labels
@eye-dee

Description

Description

Currently, Spring Data Redis allows RedisTemplate to participate in transactions by enabling setEnableTransactionSupport(true). However, declarative transaction management (@Transactional) requires a PlatformTransactionManager. The current documentation assumes that applications already have a JDBC DataSourceTransactionManager or similar, which makes Redis transactions only usable in applications that also use a database.

For applications that use Redis exclusively, there is no out-of-the-box PlatformTransactionManager implementation. This limits the ability to use @Transactional or TransactionTemplate with Redis in a consistent Spring transaction management style.

Proposed Solution

Provide a new implementation of PlatformTransactionManager specifically for Redis-only applications. Key features could include:

  • Integration with RedisTemplate and its transaction support (MULTI/EXEC/DISCARD).
  • Thread-bound connection management, similar to current transactional support when setEnableTransactionSupport(true) is enabled.
  • Support for rollback semantics if an exception occurs within a @Transactional method.
  • Minimal or no dependencies on a JDBC DataSource.

Example Usage

@Configuration
@EnableTransactionManagement
public class RedisTxOnlyConfiguration {
 @Bean
 public StringRedisTemplate redisTemplate() {
 StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory());
 template.setEnableTransactionSupport(true);
 return template;
 }
 @Bean
 public RedisConnectionFactory redisConnectionFactory() {
 // Lettuce or Jedis
 }
 @Bean
 public PlatformTransactionManager transactionManager() {
 return new RedisTransactionManager(redisTemplate());
 }
}

This would allow fully declarative @Transactional support for Redis-only applications, making transaction management consistent across Spring components.

Benefits

  • Unified transaction management for Redis-only applications.
  • Reduces the need for workaround solutions using programmatic transaction handling.
  • Aligns Redis support with Spring’s existing transaction model.

Additional Context

Related documentation: [Spring Data Redis – Transaction Support](https://docs.spring.io/spring-data/redis/docs/current/reference/html/#redis:transactions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /