mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-12-23 14:35:50 +08:00
wip: 🧠 初步的框架
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
namespace NetAdmin.Domain.Dto.Sys.Cache;
|
||||
|
||||
/// <summary>
|
||||
/// 响应:缓存统计
|
||||
/// </summary>
|
||||
public sealed record CacheStatisticsRsp : DataAbstraction
|
||||
{
|
||||
private static readonly Regex[] _regexes = {
|
||||
new(@"keyspace_hits:(\d+)", RegexOptions.Compiled)
|
||||
, new(@"keyspace_misses:(\d+)", RegexOptions.Compiled)
|
||||
, new(@"uptime_in_seconds:(\d+)", RegexOptions.Compiled)
|
||||
, new(@"used_cpu_sys:([\d\\.]+)", RegexOptions.Compiled)
|
||||
, new(@"used_cpu_user:([\d\\.]+)", RegexOptions.Compiled)
|
||||
, new(@"used_memory:(\d+)", RegexOptions.Compiled)
|
||||
, new("redis_version:(.+)", RegexOptions.Compiled)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CacheStatisticsRsp" /> class.
|
||||
/// </summary>
|
||||
public CacheStatisticsRsp() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CacheStatisticsRsp" /> class.
|
||||
/// </summary>
|
||||
public CacheStatisticsRsp(string redisResult)
|
||||
{
|
||||
KeyspaceHits = _regexes[0].Match(redisResult).Groups[1].Value.Trim().Int64Try(0);
|
||||
KeyspaceMisses = _regexes[1].Match(redisResult).Groups[1].Value.Trim().Int64Try(0);
|
||||
UpTime = _regexes[2].Match(redisResult).Groups[1].Value.Trim().Int64Try(0);
|
||||
UsedCpu = _regexes[3].Match(redisResult).Groups[1].Value.Trim().DecTry(0) +
|
||||
_regexes[4].Match(redisResult).Groups[1].Value.Trim().DecTry(0);
|
||||
UsedMemory = _regexes[5].Match(redisResult).Groups[1].Value.Trim().Int64Try(0);
|
||||
Version = _regexes[6].Match(redisResult).Groups[1].Value.Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 键总数
|
||||
/// </summary>
|
||||
public long DbSize { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 命中键的数量
|
||||
/// </summary>
|
||||
public long KeyspaceHits { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 未命中键的数量
|
||||
/// </summary>
|
||||
public long KeyspaceMisses { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Redis运行时间(秒)
|
||||
/// </summary>
|
||||
public long UpTime { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 使用的CPU时间(秒)
|
||||
/// </summary>
|
||||
public decimal UsedCpu { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 使用的内存量(字节)
|
||||
/// </summary>
|
||||
public long UsedMemory { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Redis版本号
|
||||
/// </summary>
|
||||
public string Version { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace NetAdmin.Domain.Dto.Sys.Cache;
|
||||
|
||||
/// <summary>
|
||||
/// 请求:获取所有缓存项
|
||||
/// </summary>
|
||||
public sealed record GetAllEntriesReq : DataAbstraction
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库索引号
|
||||
/// </summary>
|
||||
public uint DbIndex { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace NetAdmin.Domain.Dto.Sys.Cache;
|
||||
|
||||
/// <summary>
|
||||
/// 响应:获取所有缓存项
|
||||
/// </summary>
|
||||
public sealed record GetAllEntriesRsp : DataAbstraction
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetAllEntriesRsp" /> class.
|
||||
/// </summary>
|
||||
public GetAllEntriesRsp() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetAllEntriesRsp" /> class.
|
||||
/// </summary>
|
||||
public GetAllEntriesRsp(long absExp, string key, long sldExp, string data)
|
||||
{
|
||||
AbsExp = absExp;
|
||||
Key = key;
|
||||
SldExp = sldExp;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绝对过期时间
|
||||
/// </summary>
|
||||
public long AbsExp { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 缓存值
|
||||
/// </summary>
|
||||
public string Data { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 缓存键
|
||||
/// </summary>
|
||||
public string Key { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 滑动过期时间
|
||||
/// </summary>
|
||||
public long SldExp { get; init; }
|
||||
}
|
||||
Reference in New Issue
Block a user