Skip to content

Enable TrackLinkedCacheEntries for cache tag helpers #38190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Extensions.Caching.Memory;
Expand All @@ -20,7 +20,8 @@ public CacheTagHelperMemoryCacheFactory(IOptions<CacheTagHelperOptions> options)
{
Cache = new MemoryCache(new MemoryCacheOptions
{
SizeLimit = options.Value.SizeLimit
SizeLimit = options.Value.SizeLimit,
TrackLinkedCacheEntries = true,
});
}

Expand Down
3 changes: 1 addition & 2 deletions src/Mvc/Mvc.TagHelpers/test/CacheTagHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,14 @@ public async Task ProcessAsync_UsesExpiresSliding_ToExpireCacheEntryWithSlidingE
}

[Fact]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/36765")]
public async Task ProcessAsync_FlowsEntryLinkThatAllowsAddingTriggersToAddedEntry()
{
// Arrange
var id = "some-id";
var expectedContent = new DefaultTagHelperContent();
expectedContent.SetContent("some-content");
var tokenSource = new CancellationTokenSource();
var cache = new MemoryCache(new MemoryCacheOptions());
var cache = new MemoryCache(new MemoryCacheOptions() { TrackLinkedCacheEntries = true });
var cacheEntryOptions = new MemoryCacheEntryOptions()
.AddExpirationToken(new CancellationChangeToken(tokenSource.Token));
var tagHelperContext = new TagHelperContext(
Expand Down
1 change: 0 additions & 1 deletion src/Mvc/test/Mvc.FunctionalTests/HtmlGenerationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ public async Task CacheTagHelper_VariesByUserId()
}

[Fact]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/36765")]
public async Task CacheTagHelper_BubblesExpirationOfNestedTagHelpers()
{
// Arrange & Act - 1
Expand Down
2 changes: 2 additions & 0 deletions src/Mvc/test/WebSites/HtmlGenerationWebSite/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.TagHelpers;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;

namespace HtmlGenerationWebSite;
Expand All @@ -22,6 +23,7 @@ public void ConfigureServices(IServiceCollection services)

services.AddSingleton(typeof(ISignalTokenProviderService<>), typeof(SignalTokenProviderService<>));
services.AddSingleton<ProductsService>();
services.Configure<MemoryCacheOptions>(o => o.TrackLinkedCacheEntries = true);
}

public virtual void Configure(IApplicationBuilder app)
Expand Down