Skip to content

Commit d6f11f6

Browse files
authored
Implement clear all cache feature by * tag (#601)
1 parent fe5dbbc commit d6f11f6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/ZiggyCreatures.FusionCache/MicrosoftHybridCache/FusionHybridCache.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public sealed class FusionHybridCache
1414
: HybridCache
1515
{
1616
private const FusionCacheEntryOptions? NoEntryOptions = null;
17+
private const string ClearAllTag = "*";
1718

1819
private readonly IFusionCache _fusionCache;
1920

@@ -99,6 +100,11 @@ public override ValueTask RemoveAsync(string key, CancellationToken cancellation
99100
/// <inheritdoc/>
100101
public override ValueTask RemoveByTagAsync(string tag, CancellationToken cancellationToken = default)
101102
{
103+
if (tag == ClearAllTag)
104+
{
105+
return _fusionCache.ClearAsync(true, NoEntryOptions, cancellationToken);
106+
}
107+
102108
return _fusionCache.RemoveByTagAsync(tag, NoEntryOptions, cancellationToken);
103109
}
104110

0 commit comments

Comments
 (0)