代码片段: 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);

  

posted @ 2022-01-26 10:00  草木物语  阅读(297)  评论(0)    收藏  举报