-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial keyed services impl * Better keyed services support * Better keyed services tests * Add ChaosMemoryCache * Re-enabled package validation build step * Add support to use registered keyed services, on top of support for register it * Add specific tests
- Loading branch information
1 parent
25d6d6a
commit ca78ea4
Showing
12 changed files
with
1,011 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using Microsoft.Extensions.Caching.Memory; | ||
using Microsoft.Extensions.Logging; | ||
using ZiggyCreatures.Caching.Fusion.Chaos.Internals; | ||
|
||
namespace ZiggyCreatures.Caching.Fusion.Chaos; | ||
|
||
/// <summary> | ||
/// An implementation of <see cref="IMemoryCache"/> that acts on behalf of another one, but with a (controllable) amount of chaos in-between. | ||
/// </summary> | ||
public class ChaosMemoryCache | ||
: AbstractChaosComponent | ||
, IMemoryCache | ||
{ | ||
private readonly IMemoryCache _innerCache; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the ChaosMemoryCache class. | ||
/// </summary> | ||
/// <param name="innerCache">The actual <see cref="IMemoryCache"/> used if and when chaos does not happen.</param> | ||
/// <param name="logger">The logger to use, or <see langword="null"/>.</param> | ||
public ChaosMemoryCache(IMemoryCache innerCache, ILogger<ChaosMemoryCache>? logger = null) | ||
: base(logger) | ||
{ | ||
_innerCache = innerCache ?? throw new ArgumentNullException(nameof(innerCache)); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public ICacheEntry CreateEntry(object key) | ||
{ | ||
MaybeChaos(); | ||
return _innerCache.CreateEntry(key); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
// EMPTY | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Remove(object key) | ||
{ | ||
MaybeChaos(); | ||
_innerCache.Remove(key); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public bool TryGetValue(object key, out object? value) | ||
{ | ||
MaybeChaos(); | ||
return _innerCache.TryGetValue(key, out value); | ||
} | ||
} |
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,8 @@ | ||
// This file is used by Code Analysis to maintain SuppressMessage | ||
// attributes that are applied to this project. | ||
// Project-level suppressions either have no target or are given | ||
// a specific target and scoped to a namespace, type, member, etc. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
|
||
[assembly: SuppressMessage("Style", "IDE0290:Use primary constructor")] |
24 changes: 24 additions & 0 deletions
24
src/ZiggyCreatures.FusionCache.Chaos/ZiggyCreatures.FusionCache.Chaos.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
346 changes: 344 additions & 2 deletions
346
src/ZiggyCreatures.FusionCache/FusionCacheBuilderExtMethods.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Oops, something went wrong.