集群状态下,redis并不支持某些命令,如mset,集合的交并补运算等操作,但是springboot整合redis后并使用集群模式,发现在使用集合的交并补操作时并不会报错,且返回的结果符合预期:
@RunWith(SpringRunner.class)
@SpringBootTest
public class RedisClusterApplicationTests {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Test
public void mset() {
Map<String,String> map = new HashMap<>();
map.put("a", "a");
map.put("b", "b");
map.put("c", "c");
map.put("d", "d");
stringRedisTemplate.opsForValue().multiSet(map);
}
@Test
public void sinterTest() {
stringRedisTemplate.opsForSet().add("set1", "a","b","c");
stringRedisTemplate.opsForSet().add("set2", "a","b");
Set<String> intersect = stringRedisTemplate.opsForSet().intersect("set1", "set2");
System.out.