Pre Merge pull request !197 from Andot Studio/master

This commit is contained in:
Andot Studio 2021-09-22 01:03:29 +00:00 committed by Gitee
commit 19b8af7adc
3 changed files with 242 additions and 165 deletions

View File

@ -9,9 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
@ -48,6 +46,19 @@ public class CacheController
pieList.add(data);
});
result.put("commandStats", pieList);
result.put("allKeys", redisTemplate.keys("*"));
return AjaxResult.success(result);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:remove')")
@DeleteMapping("/{key}")
public AjaxResult delRedisCache(@PathVariable("key") String key)
{
try {
redisTemplate.delete(key);
return AjaxResult.success();
} catch (Exception exception) {
return AjaxResult.error("删除失败,请告知管理员,说明这个错误:" + exception.getMessage());
}
}
}

View File

@ -7,3 +7,19 @@ export function getCache() {
method: 'get'
})
}
// 删除缓存
export function delRedisCache(key) {
return request({
url: '/monitor/cache/'+key,
method: 'delete'
})
}
// 清空缓存
export function clearRedisCache() {
return request({
url: '/monitor/cache/clear',
method: 'delete'
})
}

View File

@ -63,6 +63,30 @@
</el-card>
</el-col>
</el-row>
<el-row>
<el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="3" v-for="key in cache.allKeys" :key="key" >
<div class="grid-content bg-purple" style="width: 95%; display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 16px;">
<div style="width: 10%; line-height: 36px; text-align: center;">
<i class="el-icon-cpu" />
</div>
<div :title="key" style="line-height: 36px; width: 80%; height: 36px; overflow: hidden; text-overflow:ellipsis; white-space:nowrap;">
<label>{{ key }}</label>
</div>
<div style="width: 10%; line-height: 36px; cursor: pointer;" @click="delCache(key)">
<i class="el-icon-delete-solid" />
</div>
</div>
</el-col>
</el-row>
<el-row>
<el-alert
title="点击清空缓存是把当前系统所用的整个index缓存库直接清空该操作不可逆请慎重操作"
type="error">
</el-alert>
</el-row>
<el-row>
<el-button type="danger" icon="el-icon-delete" @click="clearCache" style="float: right" round>清空缓存</el-button>
</el-row>
</div>
</template>
@ -148,6 +172,32 @@ export default {
background: "rgba(0, 0, 0, 0.7)",
});
},
//
delCache(key) {
this.$confirm('是否确认删除缓存"' + key + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delRedisCache(key);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
},
//
clearCache() {
this.$confirm('是否确认清空缓存? 该操作不可逆,请慎重操作!', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return clearRedisCache();
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
}
},
};
</script>