004 SpringBoot Redisのすべてのキャッシュをクリア
1035 ワード
SpringBoot Redisのすべてのキャッシュをクリア
1.先端
cleanRedis() {
let that =this
let url = '/epf-admin/admin/dictionaries/cleanRedis'
this.$confirm(' redis ?', ' ', {
confirmButtonText: ' ',
cancelButtonText: ' ',
type: 'warning'
}).then(() => {
that.$post(url,null).then(res => {
if(res.code === 0){
that.$message.success(" !")
}else{
that.$message.error(res.msg)
}
})
});
},
2.バックエンド
@Autowired
private StringRedisTemplate stringRedisTemplate;
@ApiIgnore
@RequestMapping("cleanRedis")
@ApiOperation(value=" redis ", notes="")
public R cleanRedis() {
Set keys = stringRedisTemplate.keys("*");
Iterator it1 = keys.iterator();
while (it1.hasNext()) {
stringRedisTemplate.delete(it1.next());
}
return R.ok(" !");
}