namespace Dpz.Core.Service;
/// <summary>
/// 文章浏览量的 Redis 计数器与脏集合键
/// 计数器是实时真值 由后台任务周期性同步到 MongoDB
/// </summary>
public static class ArticleViewCountKeys
{
/// <summary>
/// 待同步文章 ID 的脏集合
/// </summary>
public const string DirtySet = "dpz:article:views:dirty";
/// <summary>
/// 浏览量批量落库专用 Redis 连接在 DI 中的键
/// </summary>
internal const string FlushConnectionKey = "viewcount-flush";
/// <summary>
/// 计数器空闲过期时间 随每次浏览续期 避免删除文章后键永久残留
/// </summary>
public static readonly TimeSpan CounterTtl = TimeSpan.FromDays(30);
/// <summary>
/// 浏览量计数器键
/// </summary>
public static string BuildCounterKey(string articleId)
{
return $"dpz:article:views:count:{articleId}";
}
}
AI 正在分析代码…
评论加载中...