From 7fb5cb72f52142a891f59f77c828e801d8f75e8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= <454313500@qq.com>
Date: Sun, 18 Feb 2024 15:29:35 +0800
Subject: [PATCH] =?UTF-8?q?feat:=E5=89=8D=E7=AB=AF=E5=AF=B9=E6=8E=A5?=
=?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BC=93=E5=AD=98=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/Monitor/MonitorCacheService.cs | 33 ++++++++++++++++---
Yi.RuoYi.Vue3/src/api/monitor/cache.js | 8 ++---
.../src/views/monitor/cache/list.vue | 2 +-
3 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Monitor/MonitorCacheService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Monitor/MonitorCacheService.cs
index c6adc05f..34c0dc34 100644
--- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Monitor/MonitorCacheService.cs
+++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Monitor/MonitorCacheService.cs
@@ -38,7 +38,8 @@ namespace Yi.Framework.Rbac.Application.Services.Monitor
/// 获取所有key并分组
///
///
- public List GetName()
+ [HttpGet("monitor-cache/name")]
+ public List GetName()
{
VerifyRedisCacheEnable();
var keys = RedisClient.Keys(CacheKeyPrefix + "*");
@@ -81,21 +82,45 @@ namespace Yi.Framework.Rbac.Application.Services.Monitor
}
- [HttpGet("key/{cacaheName}")]
+ [HttpGet("monitor-cache/key/{cacaheName}")]
public List GetKey(string cacaheName)
{
VerifyRedisCacheEnable();
- var output = RedisClient.Keys($"{cacaheName}:*").Select(x => x.RemovePreFix(cacaheName+ ":"));
+ var output = RedisClient.Keys($"{cacaheName}:*").Select(x => x.RemovePreFix(cacaheName + ":"));
return output.ToList();
}
//全部不为空
- [HttpGet("value/{cacaheName}/{cacaheKey}")]
+ [HttpGet("monitor-cache/value/{cacaheName}/{cacaheKey}")]
public MonitorCacheGetListOutputDto GetValue(string cacaheName, string cacaheKey)
{
var value = RedisClient.HGet($"{cacaheName}:{cacaheKey}", "data");
return new MonitorCacheGetListOutputDto() { CacheKey = cacaheKey, CacheName = cacaheName, CacheValue = value };
}
+
+
+
+ [HttpDelete("monitor-cache/key/{cacaheName}")]
+ public bool DeleteKey(string cacaheName)
+ {
+ VerifyRedisCacheEnable();
+ RedisClient.Del($"{cacaheName}:*");
+ return true;
+ }
+
+ [HttpDelete("monitor-cache/value/{cacaheName}/{cacaheKey}")]
+ public bool DeleteValue(string cacaheName, string cacaheKey)
+ {
+ RedisClient.Del($"{cacaheName}:{cacaheKey}");
+ return true;
+ }
+
+ [HttpDelete("monitor-cache/clear")]
+ public bool DeleteClear()
+ {
+ RedisClient.FlushDb();
+ return true;
+ }
}
diff --git a/Yi.RuoYi.Vue3/src/api/monitor/cache.js b/Yi.RuoYi.Vue3/src/api/monitor/cache.js
index cf495d4c..c2c034b5 100644
--- a/Yi.RuoYi.Vue3/src/api/monitor/cache.js
+++ b/Yi.RuoYi.Vue3/src/api/monitor/cache.js
@@ -35,15 +35,15 @@ export function getCacheValue(cacheName, cacheKey) {
// 清理指定名称缓存
export function clearCacheName(cacheName) {
return request({
- url: '/monitor/cache/clearCacheName/' + cacheName,
+ url: '/monitor-cache/key/' + cacheName,
method: 'delete'
})
}
// 清理指定键名缓存
-export function clearCacheKey(cacheKey) {
+export function clearCacheKey(cacheName,cacheKey) {
return request({
- url: '/monitor/cache/clearCacheKey/' + cacheKey,
+ url: '/monitor-cache/value/'+cacheName+'/' + cacheKey,
method: 'delete'
})
}
@@ -51,7 +51,7 @@ export function clearCacheKey(cacheKey) {
// 清理全部缓存
export function clearCacheAll() {
return request({
- url: '/monitor/cache/clearCacheAll',
+ url: '/monitor-cache/clear',
method: 'delete'
})
}
diff --git a/Yi.RuoYi.Vue3/src/views/monitor/cache/list.vue b/Yi.RuoYi.Vue3/src/views/monitor/cache/list.vue
index 49ba7cdd..8db15e9c 100644
--- a/Yi.RuoYi.Vue3/src/views/monitor/cache/list.vue
+++ b/Yi.RuoYi.Vue3/src/views/monitor/cache/list.vue
@@ -207,7 +207,7 @@ function refreshCacheKeys() {
/** 清理指定键名缓存 */
function handleClearCacheKey(cacheKey) {
- clearCacheKey(cacheKey).then(response => {
+ clearCacheKey(nowCacheName.value,cacheKey).then(response => {
proxy.$modal.msgSuccess("清理缓存键名[" + cacheKey + "]成功");
getCacheKeys();
});