Redis 事务
Redis 事务
Redis事务的分析及改进:https://blog.csdn.net/kingmax54212008/article/details/82731199
SpringBoot Redis 事务
配置类
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15@Configuration
@EnableTransactionManagement//开启事务
public class BeanConfig {
@Bean
public RedisTemplate<String, Object> redisTemplate() {//创建RedisTemplate
// 配置redisTemplate
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(lettuceConnectionFactory);
setRedisTemplate(redisTemplate);
//开启事务
redisTemplate.setEnableTransactionSupport(true);
return redisTemplate;
}
}
业务代码
1 |
|
测试代码
1 |
|
Redis 事务
https://happyloves.cn/20220831/3da37e9f695f.html