-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathHttpUserAgentParserMemoryCachedProviderOptions.cs
More file actions
56 lines (48 loc) · 1.86 KB
/
HttpUserAgentParserMemoryCachedProviderOptions.cs
File metadata and controls
56 lines (48 loc) · 1.86 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright © https://myCSharp.de - all rights reserved
using Microsoft.Extensions.Caching.Memory;
namespace MyCSharp.HttpUserAgentParser.MemoryCache;
/// <summary>
/// Provider options for <see cref="HttpUserAgentParserMemoryCachedProvider"/>
/// <remarks>
/// Default of <seealso cref="MemoryCacheOptions.SizeLimit"/> is 256.
/// Default of <seealso cref="MemoryCacheEntryOptions.SlidingExpiration"/> is 1 day
/// </remarks>
/// </summary>
public class HttpUserAgentParserMemoryCachedProviderOptions
{
/// <summary>
/// Cache options
/// </summary>
public MemoryCacheOptions CacheOptions { get; }
/// <summary>
/// Cache entry options
/// </summary>
public MemoryCacheEntryOptions CacheEntryOptions { get; }
/// <summary>
/// Creates a new instance of <see cref="HttpUserAgentParserMemoryCachedProviderOptions"/>
/// </summary>
public HttpUserAgentParserMemoryCachedProviderOptions(MemoryCacheOptions cacheOptions)
: this(cacheOptions, null) { }
/// <summary>
/// Creates a new instance of <see cref="HttpUserAgentParserMemoryCachedProviderOptions"/>
/// </summary>
public HttpUserAgentParserMemoryCachedProviderOptions(MemoryCacheEntryOptions cacheEntryOptions)
: this(null, cacheEntryOptions) { }
/// <summary>
/// Creates a new instance of <see cref="HttpUserAgentParserMemoryCachedProviderOptions"/>
/// </summary>
public HttpUserAgentParserMemoryCachedProviderOptions(
MemoryCacheOptions? cacheOptions = null, MemoryCacheEntryOptions? cacheEntryOptions = null)
{
CacheEntryOptions = cacheEntryOptions ?? new MemoryCacheEntryOptions
{
// defaults
SlidingExpiration = TimeSpan.FromDays(1)
};
CacheOptions = cacheOptions ?? new MemoryCacheOptions
{
// defaults
SizeLimit = 256
};
}
}