spring-projects / spring-projects/spring-data-redis
Feature Request: PlatformTransactionManager for Redis-only Applications
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
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
RedisTemplateand 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
@Transactionalmethod. - 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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Spring Data Redis transaction-support documentation and the existing RedisTemplate behavior when setEnableTransactionSupport(true) is enabled. Define the transaction manager's scope, connection binding, MULTI/EXEC/DISCARD handling, and rollback behavior for @Transactional and TransactionTemplate use in Redis-only applications.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, redis
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100