Skip to content

[BUG] FusionHybridCache RemoveByTagAsync("*") does not invalidate whole cache #600

@vrbyjimmy

Description

@vrbyjimmy

Describe the bug

HybridCache implementation does not clear all data when called RemoveByTagAsync("*") as is specified by Microsoft documentation

To Reproduce

using Microsoft.Extensions.Caching.Hybrid;
using Microsoft.Extensions.DependencyInjection;
using ZiggyCreatures.Caching.Fusion;

var serviceProvider = new ServiceCollection()
.AddFusionCache()
.WithDefaultEntryOptions(options =>
{
options.Duration = TimeSpan.FromMinutes(10);
})
.AsHybridCache()
.Services
.BuildServiceProvider();

var cache = serviceProvider.GetRequiredService<HybridCache>();

await cache.SetAsync("Key", "NotExpected");

await cache.RemoveByTagAsync("*");

var value = await cache.GetOrCreateAsync("Key", async t => await Task.FromResult("Expected"));

if (value != "Expected")
{
throw new Exception("Unexpected value: " + value);
}

Expected behavior

After calling RemoveByTagAsync("*") all data in cache should be removed

Versions

I've encountered this issue on:

  • FusionCache: 2.5.0
  • .NET version: 10.0
  • OS version: Windows 11

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions