-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create the configuration cache in the BaseConfigurationManager class (#…
…2048) * create the configuration cache in the BaseConfigurationManager class * added a test * moved all fields/properties of the LastKnownGoodConfigurationCacheOptions class to LKGConfigurationCacheOptions so they are more accessible * added TaskCreationOptions and RemoveExpiredValues to LKGConfigurationCacheOptions * added the DefaultLastKnownGoodConfigurationSizeLimit property to fix an ApiCompat error * review feedback
- Loading branch information
1 parent
614642a
commit 2eb488a
Showing
7 changed files
with
92 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 6 additions & 36 deletions
42
...Microsoft.IdentityModel.Protocols/Configuration/LastKnownGoodConfigurationCacheOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,20 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Microsoft.IdentityModel.Tokens; | ||
using Microsoft.IdentityModel.Logging; | ||
using Microsoft.IdentityModel.Tokens.Configuration; | ||
|
||
namespace Microsoft.IdentityModel.Protocols.Configuration | ||
{ | ||
/// <summary> | ||
/// Specifies the LastKnownGoodConfigurationCacheOptions which can be used to configure the internal LKG configuration cache. | ||
/// See <see cref="EventBasedLRUCache{TKey, TValue}"/> for more details. | ||
/// | ||
/// All fields/properties are now defined in the Microsoft.IdentityModel.Tokens.Configuration.LKGConfigurationCacheOptions class so they are more accessible from other assemblies/classes. | ||
/// </summary> | ||
public class LastKnownGoodConfigurationCacheOptions | ||
public class LastKnownGoodConfigurationCacheOptions : LKGConfigurationCacheOptions | ||
{ | ||
private IEqualityComparer<BaseConfiguration> _baseConfigurationComparer = new BaseConfigurationComparer(); | ||
private int _lastKnownGoodConfigurationSizeLimit = DefaultLastKnownGoodConfigurationSizeLimit; | ||
|
||
/// <summary> | ||
/// 10 is the default size limit of the cache (in number of items) for last known good configuration. | ||
/// </summary> | ||
public static readonly int DefaultLastKnownGoodConfigurationSizeLimit = 10; | ||
|
||
/// <summary> | ||
/// Gets or sets the BaseConfgiurationComparer that to compare <see cref="BaseConfiguration"/>. | ||
/// </summary> | ||
public IEqualityComparer<BaseConfiguration> BaseConfigurationComparer | ||
{ | ||
get { return _baseConfigurationComparer; } | ||
set | ||
{ | ||
_baseConfigurationComparer = value ?? throw LogHelper.LogExceptionMessage(new ArgumentNullException(nameof(value))); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The size limit of the cache (in number of items) for last known good configuration. | ||
/// </summary> | ||
public int LastKnownGoodConfigurationSizeLimit | ||
{ | ||
get { return _lastKnownGoodConfigurationSizeLimit; } | ||
set | ||
{ | ||
_lastKnownGoodConfigurationSizeLimit = (value > 0) ? value : throw LogHelper.LogExceptionMessage(new ArgumentOutOfRangeException(nameof(value))); | ||
} | ||
} | ||
/// <inheritdoc/> | ||
public static readonly int DefaultLastKnownGoodConfigurationSizeLimit = LKGConfigurationCacheOptions.DefaultLKGConfigurationSizeLimit; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/Microsoft.IdentityModel.Tokens/Configuration/LKGConfigurationCacheOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.IdentityModel.Tokens.Configuration | ||
{ | ||
/// <summary> | ||
/// Defines the options which can be used to configure the internal LKG configuration cache. | ||
/// See <see cref="EventBasedLRUCache{TKey, TValue}"/> for more details. | ||
/// </summary> | ||
public class LKGConfigurationCacheOptions | ||
{ | ||
private IEqualityComparer<BaseConfiguration> _baseConfigurationComparer = new BaseConfigurationComparer(); | ||
private int _lastKnownGoodConfigurationSizeLimit = DefaultLKGConfigurationSizeLimit; | ||
|
||
/// <summary> | ||
/// 10 is the default size limit of the cache (in number of items) for last known good configuration. | ||
/// </summary> | ||
public static readonly int DefaultLKGConfigurationSizeLimit = 10; | ||
|
||
/// <summary> | ||
/// Gets or sets the BaseConfgiurationComparer that to compare <see cref="BaseConfiguration"/>. | ||
/// </summary> | ||
public IEqualityComparer<BaseConfiguration> BaseConfigurationComparer | ||
{ | ||
get { return _baseConfigurationComparer; } | ||
set { _baseConfigurationComparer = value ?? throw new ArgumentNullException(nameof(value)); } | ||
} | ||
|
||
/// <summary> | ||
/// The size limit of the cache (in number of items) for last known good configuration. | ||
/// </summary> | ||
public int LastKnownGoodConfigurationSizeLimit | ||
{ | ||
get { return _lastKnownGoodConfigurationSizeLimit; } | ||
set { _lastKnownGoodConfigurationSizeLimit = (value > 0) ? value : throw new ArgumentOutOfRangeException(nameof(value)); } | ||
} | ||
|
||
/// <summary> | ||
/// The event queue task creation option, default to None instead of LongRunning as LongRunning will always start a task on a new thread instead of a thread from ThreadPool. | ||
/// </summary> | ||
public TaskCreationOptions TaskCreationOptions { get; set; } = TaskCreationOptions.None; | ||
|
||
/// <summary> | ||
/// Whether or not to remove expired items. | ||
/// </summary> | ||
public bool RemoveExpiredValues { get; set; } = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters