代码片段: redis按前缀批量删除
ValueOperations<String, String> operations = stringRedisTemplate.opsForValue();
Map<String, String> map = new HashMap<>();
map.put("str_a", "a");
map.put("str_b", "b");
operations.multiSet(map);
Set<String> keys = stringRedisTemplate.keys("str_*");
System.out.println(keys);
assert keys != null;
stringRedisTemplate.delete(keys);

浙公网安备 33010602011771号