Files
Yi.Admin/Yi.Furion.Net6/Yi.Furion.Application/Rbac/Services/Impl/MonitorCacheService.cs

53 lines
2.0 KiB
C#
Raw Normal View History

2023-04-19 11:19:36 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2023-04-19 13:39:55 +08:00
using CSRedis;
using Furion.ClayObject.Extensions;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
2023-04-19 11:19:36 +08:00
using Microsoft.Extensions.Caching.Memory;
2023-04-19 13:39:55 +08:00
using Yi.Framework.Module.Caching;
2023-04-19 11:19:36 +08:00
using Yi.Furion.Core.Rbac.Dtos.MonitorCache;
namespace Yi.Furion.Application.Rbac.Services.Impl
{
2023-04-19 13:39:55 +08:00
public class MonitorCacheService : IMonitorCacheService, IDynamicApiController, ITransient
2023-04-19 11:19:36 +08:00
{
2023-04-19 13:39:55 +08:00
private static List<MonitorCacheNameGetListOutputDto> monitorCacheNames => new List<MonitorCacheNameGetListOutputDto>()
2023-04-19 11:19:36 +08:00
{
2023-04-19 13:39:55 +08:00
new MonitorCacheNameGetListOutputDto{ CacheName="Yi:Login",Remark="登录验证码"},
new MonitorCacheNameGetListOutputDto{ CacheName="Yi:User",Remark="用户信息"}
};
private Dictionary<string, string> monitorCacheNamesDic => monitorCacheNames.ToDictionary(x => x.CacheName, x => x.Remark);
private CSRedisClient _cacheClient;
public MonitorCacheService(RedisCacheClient redisCacheClient)
{
_cacheClient = redisCacheClient.Client;
2023-04-19 11:19:36 +08:00
}
//cacheKey value为空只要name和备注
public List<MonitorCacheNameGetListOutputDto> GetName()
{
2023-04-19 13:39:55 +08:00
//固定的
return monitorCacheNames;
2023-04-19 11:19:36 +08:00
}
[HttpGet("key/{cacaheName}")]
public List<string> GetKey([FromRoute] string cacaheName)
{
2023-04-19 13:39:55 +08:00
var output = _cacheClient.Keys($"{cacaheName}:*");
return new List<string>() { "1233124", "3124", "1231251", "12312412" };
2023-04-19 11:19:36 +08:00
}
//全部不为空
[HttpGet("value/{cacaheName}/{cacaheKey}")]
public MonitorCacheGetListOutputDto GetValue([FromRoute] string cacaheName, [FromRoute] string cacaheKey)
{
2023-04-19 13:39:55 +08:00
var value = _cacheClient.Get($"{cacaheName}:{cacaheKey}");
return new MonitorCacheGetListOutputDto() { CacheKey = cacaheKey, CacheName = cacaheName, CacheValue = "ttt", Remark = monitorCacheNamesDic[cacaheName] };
2023-04-19 11:19:36 +08:00
}
}
}