-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CacheOptions.cs
47 lines (45 loc) · 1.64 KB
/
CacheOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace RentmanSharp
{
public readonly struct CacheOptions
{
private static ILogger? _logger;
private static ILogger logger
{
get
{
if (_logger == null)
_logger = ApplicationLogging.LoggerFactory.CreateLogger(typeof(CacheOptions));
return _logger;
}
}
public static CacheOptions Disabled = new CacheOptions();
public static CacheOptions Default = new CacheOptions(new TimeOnly(0, 0, 30), new TimeOnly(8, 0), new TimeOnly(0, 30));
public readonly bool Enabled = false;
public readonly TimeOnly Delay = TimeOnly.MinValue;
public readonly TimeOnly CroneInterval = TimeOnly.MinValue;
public readonly TimeOnly IncrementInterval = TimeOnly.MinValue;
public readonly byte ParallelLimit = 5;
public readonly Type[] CachedEndpoints = new Type[0];
public CacheOptions()
{
}
public CacheOptions(TimeOnly delay, TimeOnly croneInterval, TimeOnly incrementInterval, byte parallelLimit = 3, params Type[] cachedEndpoints) : this()
{
Enabled = true;
Delay = delay;
CroneInterval = croneInterval;
IncrementInterval = incrementInterval;
ParallelLimit = parallelLimit;
try
{
if (cachedEndpoints == null || cachedEndpoints.Length == 0)
return;
CachedEndpoints = cachedEndpoints;
}
catch(Exception e)
{
logger.LogDebug(e, string.Empty);
}
}
}
}