-
Notifications
You must be signed in to change notification settings - Fork 14
MultiTenant breaks OutputCache EvictCacheAsync() #7
Copy link
Copy link
Open
Description
Hi @myquay
The issue occurs if OutputCache is used alongside your library.
This is an odd one which has me stumped - I've attached a minimal project to demonstrate
When you configure the OutputCache outside the tenant container
builder
.Services
.AddOutputCache(options => options
.AddBasePolicy(config => config.Tag("TagA").Expire(TimeSpan.FromSeconds(10)))
);This sets up a singleton for the IOutputCacheStore as follows:
public static IServiceCollection AddOutputCache(this IServiceCollection services)
{
ArgumentNullException.ThrowIfNull(services);
services.AddTransient<IConfigureOptions<OutputCacheOptions>, OutputCacheOptionsSetup>();
services.TryAddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
services.TryAddSingleton<IOutputCacheStore>(sp =>
{
var outputCacheOptions = sp.GetRequiredService<IOptions<OutputCacheOptions>>();
return new MemoryOutputCacheStore(new MemoryCache(new MemoryCacheOptions
{
SizeLimit = outputCacheOptions.Value.SizeLimit
}));
});
return services;
}But when you evict the cache using it's tag inside the tenant container as follows:
public void Handle()
{
_cacheStore.EvictByTagAsync("TagA", CancellationToken.None);
}The _cacheStore is always empty. I checked the hashcode in the Post handler and my command handler and it looks like the same instance
When commenting out the Multitenant container and calling the Handle() normally in the main service container it works fine.
Here the minimal project
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels