【redis cluster】redis-cluster事务测试
关于spring-data-redis对redis事务的支持:
转载https://www.cnblogs.com/grey-wolf/p/10142937.html
测试用例:
@Test
void redisClusterTractionTest() {
Object res=redisTemplate.execute(new SessionCallback<Object>() {
@Override
public Object execute(RedisOperations operations) throws DataAccessException {
operations.multi();
operations.opsForValue().get("lcc");
operations.opsForValue().get("clc");
operations.opsForValue().get("ccl");
operations.exec();
return null;
}
});
System.out.println(res);
}
}
执行结果:

是不是很熟悉 和之前pipeline一样
org.springframework.data.redis.connection.jedis.JedisClusterConnection#multi:


可以看到如果这里是一个clusterConnection直接就抛出异常了

浙公网安备 33010602011771号