wip: 🧠 初步的框架

This commit is contained in:
tk
2023-08-25 15:33:42 +08:00
parent 57c1ba2002
commit 18b4d7547a
1014 changed files with 122380 additions and 2 deletions

View File

@@ -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; }
}

View File

@@ -0,0 +1,12 @@
namespace NetAdmin.Domain.Dto.Sys.Cache;
/// <summary>
/// 请求:获取所有缓存项
/// </summary>
public sealed record GetAllEntriesReq : DataAbstraction
{
/// <summary>
/// 数据库索引号
/// </summary>
public uint DbIndex { get; init; }
}

View File

@@ -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; }
}