26 lines
661 B
C#
26 lines
661 B
C#
|
using System;
|
|||
|
|
|||
|
namespace Mirea.Api.Endpoint.Common.Attributes;
|
|||
|
|
|||
|
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
|||
|
public class CacheMaxAgeAttribute : Attribute
|
|||
|
{
|
|||
|
public int MaxAge { get; }
|
|||
|
|
|||
|
public CacheMaxAgeAttribute(int days = 0, int hours = 0, int minutes = 0)
|
|||
|
{
|
|||
|
MaxAge = (int)new TimeSpan(days, hours, minutes, 0).TotalSeconds;
|
|||
|
}
|
|||
|
|
|||
|
public CacheMaxAgeAttribute(int minutes) : this(0, 0, minutes)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public CacheMaxAgeAttribute(bool usingSetting = false)
|
|||
|
{
|
|||
|
if (usingSetting)
|
|||
|
MaxAge = -1;
|
|||
|
else
|
|||
|
MaxAge = 0;
|
|||
|
}
|
|||
|
}
|