feat:前端对接完成缓存模块

This commit is contained in:
陈淳
2024-02-18 15:29:35 +08:00
parent 798cb92f50
commit 7fb5cb72f5
3 changed files with 34 additions and 9 deletions

View File

@@ -38,7 +38,8 @@ namespace Yi.Framework.Rbac.Application.Services.Monitor
/// 获取所有key并分组
/// </summary>
/// <returns></returns>
public List<MonitorCacheNameGetListOutputDto> GetName()
[HttpGet("monitor-cache/name")]
public List<MonitorCacheNameGetListOutputDto> 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<string> 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;
}
}

View File

@@ -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'
})
}

View File

@@ -207,7 +207,7 @@ function refreshCacheKeys() {
/** 清理指定键名缓存 */
function handleClearCacheKey(cacheKey) {
clearCacheKey(cacheKey).then(response => {
clearCacheKey(nowCacheName.value,cacheKey).then(response => {
proxy.$modal.msgSuccess("清理缓存键名[" + cacheKey + "]成功");
getCacheKeys();
});