Add project files.
This commit is contained in:
69
JSMR.Application/Common/Caching/CacheEntryOptions.cs
Normal file
69
JSMR.Application/Common/Caching/CacheEntryOptions.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
namespace JSMR.Application.Common.Caching;
|
||||
|
||||
public class CacheEntryOptions
|
||||
{
|
||||
private DateTimeOffset? _absoluteExpiration;
|
||||
private TimeSpan? _absoluteExpirationRelativeToNow;
|
||||
private TimeSpan? _slidingExpiration;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an absolute expiration date for the cache entry.
|
||||
/// </summary>
|
||||
public DateTimeOffset? AbsoluteExpiration
|
||||
{
|
||||
get
|
||||
{
|
||||
return _absoluteExpiration;
|
||||
}
|
||||
set
|
||||
{
|
||||
_absoluteExpiration = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an absolute expiration time, relative to now.
|
||||
/// </summary>
|
||||
public TimeSpan? AbsoluteExpirationRelativeToNow
|
||||
{
|
||||
get
|
||||
{
|
||||
return _absoluteExpirationRelativeToNow;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value <= TimeSpan.Zero)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(AbsoluteExpirationRelativeToNow),
|
||||
value,
|
||||
"The relative expiration value must be positive.");
|
||||
}
|
||||
|
||||
_absoluteExpirationRelativeToNow = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets how long a cache entry can be inactive (e.g. not accessed) before it will be removed.
|
||||
/// This will not extend the entry lifetime beyond the absolute expiration (if set).
|
||||
/// </summary>
|
||||
public TimeSpan? SlidingExpiration
|
||||
{
|
||||
get
|
||||
{
|
||||
return _slidingExpiration;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value <= TimeSpan.Zero)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(SlidingExpiration),
|
||||
value,
|
||||
"The sliding expiration value must be positive.");
|
||||
}
|
||||
_slidingExpiration = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user