Files
OSS.Tools/Cache/OSS.Tools.Cache/CacheOptions.cs
T
2020-11-25 17:19:37 +08:00

58 lines
1.7 KiB
C#
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#region Copyright (C) 2016 Kevin (OSS开源系列) 公众号:OSSCore
/***************************************************************************
*   文件功能描述:全局插件 - 缓存选项
*
*   创建人: Kevin
* 创建人Email:1985088337@qq.com
*
*
*****************************************************************************/
#endregion
using System;
namespace OSS.Tools.Cache
{
public class CacheTimeOptions
{
private TimeSpan? _absoluteExpirationRelativeNow;
private TimeSpan? _slidingExpiration;
/// <summary>
/// 固定过期时长,设置后到时过期
/// </summary>
public TimeSpan? AbsoluteExpirationRelativeToNow
{
get => _absoluteExpirationRelativeNow;
set
{
var a = value;
if (a.HasValue&&a.Value<=TimeSpan.Zero)
throw new ArgumentOutOfRangeException(nameof(AbsoluteExpirationRelativeToNow), value, "The relative expiration value must be positive.");
_absoluteExpirationRelativeNow = value;
}
}
/// <summary>
/// 滚动过期时长,访问后自动延长
/// </summary>
public TimeSpan? SlidingExpiration
{
get => _slidingExpiration;
set
{
var a = value;
if (a.HasValue && a.Value <= TimeSpan.Zero)
throw new ArgumentOutOfRangeException(nameof(SlidingExpiration), (object) value, "The relative expiration value must be positive.");
_slidingExpiration = value;
}
}
}
}