using System;
namespace LiveForum.Code.AttributeExtend
{
///
/// 响应缓存特性,用于标记需要缓存的Action方法
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class ResponseCacheExtendAttribute : Attribute
{
///
/// 缓存时间(秒),默认3600秒(1小时)
///
public int Duration { get; set; } = 3600;
///
/// 影响缓存Key的查询参数名称数组(参数排序后参与Key生成)
/// 例如:["AgreementType"] 或 ["Platform", "CurrentVersion"]
///
public string[] VaryByQueryKeys { get; set; }
///
/// 自定义缓存Key前缀,默认使用路径(api/{Controller}/{Action})
///
public string CacheKeyPrefix { get; set; }
///
/// 是否启用缓存,默认true
///
public bool Enabled { get; set; } = true;
///
/// 构造函数
///
public ResponseCacheExtendAttribute()
{
}
///
/// 构造函数
///
/// 缓存时间(秒)
public ResponseCacheExtendAttribute(int duration)
{
Duration = duration;
}
}
}