-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCacheHandleConfiguration.cs
100 lines (86 loc) · 3.72 KB
/
CacheHandleConfiguration.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
namespace Nerosoft.Euonia.Caching;
/// <summary>
/// Defines all settings the cache handle should respect.
/// </summary>
public sealed class CacheHandleConfiguration
{
/// <summary>
/// Initializes a new instance of the <see cref="CacheHandleConfiguration"/> class.
/// </summary>
public CacheHandleConfiguration()
{
Name = Key = Guid.NewGuid().ToString();
}
/// <summary>
/// Initializes a new instance of the <see cref="CacheHandleConfiguration"/> class.
/// </summary>
/// <param name="handleName">Name of the handle. This value will also be used for the <see cref="Key"/>.</param>
/// <exception cref="ArgumentNullException">If <paramref name="handleName"/> is null.</exception>
public CacheHandleConfiguration(string handleName)
{
Check.EnsureNotNullOrWhiteSpace(handleName, nameof(handleName));
Name = Key = handleName;
}
/// <summary>
/// Initializes a new instance of the <see cref="CacheHandleConfiguration"/> class.
/// </summary>
/// <param name="handleName">Name of the handle.</param>
/// <param name="configurationKey">The key which can be used to identify another part of the configuration which the handle might need.</param>
/// <exception cref="ArgumentNullException">
/// If <paramref name="handleName"/> or <paramref name="configurationKey"/> is null.
/// </exception>
public CacheHandleConfiguration(string handleName, string configurationKey)
{
Check.EnsureNotNullOrWhiteSpace(handleName, nameof(handleName));
Check.EnsureNotNullOrWhiteSpace(configurationKey, nameof(configurationKey));
Name = handleName;
Key = configurationKey;
}
/// <summary>
/// Gets or sets a value indicating whether statistics should be enabled.
/// </summary>
/// <value><c>true</c> if statistics should be enabled; otherwise, <c>false</c>.</value>
public bool EnableStatistics { get; set; }
/// <summary>
/// Gets or sets the expiration mode.
/// </summary>
/// <value>The expiration mode.</value>
public CacheExpirationMode ExpirationMode { get; set; }
/// <summary>
/// Gets or sets the expiration timeout.
/// </summary>
/// <value>The expiration timeout.</value>
public TimeSpan ExpirationTimeout { get; set; }
/// <summary>
/// Gets or sets the name for the cache handle which is also the identifier of the configuration.
/// </summary>
/// <value>The name of the handle.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the configuration key.
/// Some cache handles require to reference another part of the configuration by name.
/// If not specified, the <see cref="Name"/> will be used instead.
/// </summary>
public string Key { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is backplane source.
/// <para>
/// Only one cache handle inside one cache manager can be backplane source. Usually this is
/// a distributed cache. It might not make any sense to define an in process cache as backplane source.
/// </para>
/// <para>If no backplane is configured for the cache, this setting will have no effect.</para>
/// </summary>
/// <value><c>true</c> if this instance should be backplane source; otherwise, <c>false</c>.</value>
public bool IsBackplaneSource { get; set; }
/// <summary>
/// Gets or sets the type of the handle.
/// </summary>
/// <value>The type of the handle.</value>
public Type HandleType { get; set; }
internal object[] ConfigurationTypes { get; set; } = Array.Empty<object>();
/// <inheritdoc />
public override string ToString()
{
return $"{HandleType}";
}
}