CSharp-Single-EFCore/Bunny.Common/Attribute/CacheableAttribute.cs

11 lines
394 B
C#
Raw Normal View History

namespace Bunny.Common.Attribute;
[AttributeUsage(AttributeTargets.Method)]
public class CacheableAttribute(string key, string durationString) : System.Attribute
{
// 构造函数接收一个表示时间的字符串参数
// 将字符串转换为TimeSpan
public string? Key { get; set; } = key;
public TimeSpan TimeDuration { get; set; } = TimeSpan.Parse(durationString);
}