004 SpringBoot 清空Redis所有缓存

Myth丶恋晨 2024-04-18 09:30 99阅读 0赞

SpringBoot 清空Redis所有缓存

1.前端

  1. cleanRedis() {
  2. let that =this
  3. let url = '/epf-admin/admin/dictionaries/cleanRedis'
  4. this.$confirm('确定要清空redis缓存吗?', '提示', {
  5. confirmButtonText: '确定',
  6. cancelButtonText: '取消',
  7. type: 'warning'
  8. }).then(() => {
  9. that.$post(url,null).then(res => {
  10. if(res.code === 0){
  11. that.$message.success("清空成功!")
  12. }else{
  13. that.$message.error(res.msg)
  14. }
  15. })
  16. });
  17. },

2.后端

  1. @Autowired
  2. private StringRedisTemplate stringRedisTemplate;
  3. @ApiIgnore
  4. @RequestMapping("cleanRedis")
  5. @ApiOperation(value="清空redis缓存", notes="")
  6. public R cleanRedis() {
  7. Set<String> keys = stringRedisTemplate.keys("*");
  8. Iterator<String> it1 = keys.iterator();
  9. while (it1.hasNext()) {
  10. stringRedisTemplate.delete(it1.next());
  11. }
  12. return R.ok("操作成功!");
  13. }

发表评论

表情:
评论列表 (有 0 条评论,99人围观)

还没有评论,来说两句吧...

相关阅读