-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathCacheConfiguration.cs
More file actions
36 lines (32 loc) · 1.53 KB
/
CacheConfiguration.cs
File metadata and controls
36 lines (32 loc) · 1.53 KB
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
using System;
namespace Arcus.Security.Core.Caching.Configuration
{
/// <summary>
/// Default implementation of the collected configuration values to control the caching when interacting with Azure Key Vault.
/// </summary>
[Obsolete("Will be removed in v3.0 as caching will be handled by the secret store itself", DiagnosticId = ObsoleteDefaults.DiagnosticId)]
public class CacheConfiguration : ICacheConfiguration
{
/// <summary>
/// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
/// </summary>
/// <param name="duration">Duration for which an entry should be cached</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown when the cache duration is not a positive time duration.</exception>
public CacheConfiguration(TimeSpan duration)
{
if (duration < TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(duration), duration, "Requires a positive time duration in which the caching should take place");
}
Duration = duration;
}
/// <summary>
/// Gets the default <see cref="ICacheConfiguration"/> that takes in 5 minutes as default cache duration.
/// </summary>
public static ICacheConfiguration Default { get; } = new CacheConfiguration(TimeSpan.FromMinutes(5));
/// <summary>
/// Gets the duration for which an entry should be cached.
/// </summary>
public TimeSpan Duration { get; }
}
}