Do not add the configuration for CacheTagHelperOptions to the container multiple times
This commit is contained in:
parent
0c07e1e725
commit
c43da19ff1
|
|
@ -12,6 +12,6 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
/// The maximum total size in bytes that will be cached by the <see cref="CacheTagHelper"/>
|
/// The maximum total size in bytes that will be cached by the <see cref="CacheTagHelper"/>
|
||||||
/// at any given time.
|
/// at any given time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long SizeLimit { get; set; }
|
public long SizeLimit { get; set; } = 100 * 1024 * 1024; // 100MB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class TagHelperServicesExtensions
|
public static class TagHelperServicesExtensions
|
||||||
{
|
{
|
||||||
private const int DefaultCacheMaximumSizeInBytes = 100 * 1024 * 1024; // 100MB
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds MVC cache tag helper services to the application.
|
/// Adds MVC cache tag helper services to the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -35,7 +33,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
// Required default services for cache tag helpers
|
// Required default services for cache tag helpers
|
||||||
builder.Services.AddDistributedMemoryCache();
|
builder.Services.AddDistributedMemoryCache();
|
||||||
builder.Services.TryAddSingleton<CacheTagHelperMemoryCacheFactory>();
|
builder.Services.TryAddSingleton<CacheTagHelperMemoryCacheFactory>();
|
||||||
builder.AddCacheTagHelperLimits(options => options.SizeLimit = DefaultCacheMaximumSizeInBytes);
|
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue