feature(Redis监控): 添加缓存列表

This commit is contained in:
luowenfeng 2022-07-07 14:50:58 +08:00
parent 797be10752
commit a7067ea6fd
3 changed files with 18 additions and 15 deletions

View File

@ -43,7 +43,7 @@ public class RedisController {
} }
@GetMapping("/get-key-list") @GetMapping("/get-key-list")
@ApiOperation("获得 Redis Key 列表") @ApiOperation("获得 Redis Key 模板列表")
@PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')") @PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')")
public CommonResult<List<RedisKeyRespVO>> getKeyList() { public CommonResult<List<RedisKeyRespVO>> getKeyList() {
List<RedisKeyDefine> keyDefines = RedisKeyRegistry.list(); List<RedisKeyDefine> keyDefines = RedisKeyRegistry.list();
@ -51,37 +51,40 @@ public class RedisController {
} }
@GetMapping("/get-key/{keyDefine}") @GetMapping("/get-key/{keyDefine}")
@ApiOperation("获得 Redis Key") @ApiOperation("获得 Redis keys 键名列表")
// @PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')") @PreAuthorize("@ss.hasPermission('infra:redis:get-key-define')")
public CommonResult<Set<String>> getKeyDefineKeys(@PathVariable("keyDefine") String keyDefine) { public CommonResult<Set<String>> getKeyDefineKeys(@PathVariable("keyDefine") String keyDefine) {
Set<String> Keys = stringRedisTemplate.keys(keyDefine + "*"); Set<String> Keys = stringRedisTemplate.keys(keyDefine + "*");
return success(Keys); return success(Keys);
} }
@DeleteMapping("/clear-key/{keyDefine}") @DeleteMapping("/clear-key/{keyDefine}")
@ApiOperation("获得 Redis Key") @ApiOperation("删除 Redis Key 根据模板")
// @PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')") @PreAuthorize("@ss.hasPermission('infra:redis:clear-key-define')")
public CommonResult<Boolean> clearKeyDefineKeys(@PathVariable("keyDefine") String keyDefine) { public CommonResult<Boolean> clearKeyDefineKeys(@PathVariable("keyDefine") String keyDefine) {
stringRedisTemplate.delete(Objects.requireNonNull(stringRedisTemplate.keys(keyDefine + "*"))); stringRedisTemplate.delete(Objects.requireNonNull(stringRedisTemplate.keys(keyDefine + "*")));
return success(Boolean.TRUE); return success(Boolean.TRUE);
} }
// @PreAuthorize("@ss.hasPermi('monitor:cache:list')") @GetMapping("/get-key/{keyDefine}/{cacheKey}")
@GetMapping("/get-key/{cacheName}/{cacheKey}") @ApiOperation("获得 Redis key 内容")
public CommonResult<RedisValuesRespVO> getKeyValue(@PathVariable("cacheName") String cacheName, @PathVariable("cacheKey") String cacheKey) { @PreAuthorize("@ss.hasPermission('infra:redis:get-key-value')")
public CommonResult<RedisValuesRespVO> getKeyValue(@PathVariable("keyDefine") String keyDefine, @PathVariable("cacheKey") String cacheKey) {
String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey); String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey);
return success(new RedisValuesRespVO(cacheName, cacheKey, cacheValue)); return success(new RedisValuesRespVO(keyDefine, cacheKey, cacheValue));
} }
// @PreAuthorize("@ss.hasPermi('monitor:cache:list')") @DeleteMapping("/clear-key/{cacheKey}")
@DeleteMapping("/clearCacheKey/{cacheKey}") @ApiOperation("删除 Redis Key 根据key")
@PreAuthorize("@ss.hasPermission('infra:redis:clear-key-value')")
public CommonResult<Boolean> clearCacheKey(@PathVariable String cacheKey) { public CommonResult<Boolean> clearCacheKey(@PathVariable String cacheKey) {
stringRedisTemplate.delete(cacheKey); stringRedisTemplate.delete(cacheKey);
return success(Boolean.TRUE); return success(Boolean.TRUE);
} }
// @PreAuthorize("@ss.hasPermi('monitor:cache:list')") @DeleteMapping("/clear-cache-all")
@DeleteMapping("/clearCacheAll") @ApiOperation(value="删除 所有缓存", notes="不使用该接口")
@PreAuthorize("@ss.hasPermission('infra:redis:clear-cache-all')")
public CommonResult<Boolean> clearCacheAll() { public CommonResult<Boolean> clearCacheAll() {
Collection<String> cacheKeys = stringRedisTemplate.keys("*"); Collection<String> cacheKeys = stringRedisTemplate.keys("*");
stringRedisTemplate.delete(cacheKeys); stringRedisTemplate.delete(cacheKeys);

View File

@ -35,7 +35,7 @@ export function getKeyValue(keyDefine, key) {
// 根据键名删除缓存 // 根据键名删除缓存
export function clearCacheKey(key) { export function clearCacheKey(key) {
return request({ return request({
url: '/infra/redis/clearCacheKey/' + key, url: '/infra/redis/clear-key/' + key,
method: 'delete' method: 'delete'
}) })
} }

View File

@ -93,7 +93,7 @@
<el-dialog <el-dialog
:title="keyTemplate + '模块'" :title="keyTemplate + '模块'"
:visible.sync="open" :visible.sync="open"
width="50vw" width="60vw"
append-to-body append-to-body
> >
<el-row :gutter="10"> <el-row :gutter="10">