Move ResponseCaching pubternal types to internal (#9392)

This commit is contained in:
John Luo 2019-04-16 15:14:59 -07:00 committed by GitHub
parent 039e505160
commit c2ee82b49e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 27 additions and 102 deletions

View File

@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
}
public partial class ResponseCachingMiddleware
{
public ResponseCachingMiddleware(Microsoft.AspNetCore.Http.RequestDelegate next, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.ResponseCaching.ResponseCachingOptions> options, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCachingPolicyProvider policyProvider, Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCachingKeyProvider keyProvider) { }
public ResponseCachingMiddleware(Microsoft.AspNetCore.Http.RequestDelegate next, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.ResponseCaching.ResponseCachingOptions> options, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, Microsoft.Extensions.ObjectPool.ObjectPoolProvider poolProvider) { }
[System.Diagnostics.DebuggerStepThroughAttribute]
public System.Threading.Tasks.Task Invoke(Microsoft.AspNetCore.Http.HttpContext httpContext) { throw null; }
}
@ -29,80 +29,6 @@ namespace Microsoft.AspNetCore.ResponseCaching
public bool UseCaseSensitivePaths { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
}
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public partial class CachedResponse : Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCacheEntry
{
public CachedResponse() { }
public System.IO.Stream Body { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public System.DateTimeOffset Created { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public Microsoft.AspNetCore.Http.IHeaderDictionary Headers { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public int StatusCode { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
public partial class CachedVaryByRules : Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCacheEntry
{
public CachedVaryByRules() { }
public Microsoft.Extensions.Primitives.StringValues Headers { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public Microsoft.Extensions.Primitives.StringValues QueryKeys { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public string VaryByKeyPrefix { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
public partial interface IResponseCache
{
Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCacheEntry Get(string key);
System.Threading.Tasks.Task<Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCacheEntry> GetAsync(string key);
void Set(string key, Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCacheEntry entry, System.TimeSpan validFor);
System.Threading.Tasks.Task SetAsync(string key, Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCacheEntry entry, System.TimeSpan validFor);
}
public partial interface IResponseCacheEntry
{
}
public partial interface IResponseCachingKeyProvider
{
string CreateBaseKey(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context);
System.Collections.Generic.IEnumerable<string> CreateLookupVaryByKeys(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context);
string CreateStorageVaryByKey(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context);
}
public partial interface IResponseCachingPolicyProvider
{
bool AllowCacheLookup(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context);
bool AllowCacheStorage(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context);
bool AttemptResponseCaching(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context);
bool IsCachedEntryFresh(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context);
bool IsResponseCacheable(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context);
}
public partial class MemoryResponseCache : Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCache
{
public MemoryResponseCache(Microsoft.Extensions.Caching.Memory.IMemoryCache cache) { }
public Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCacheEntry Get(string key) { throw null; }
public System.Threading.Tasks.Task<Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCacheEntry> GetAsync(string key) { throw null; }
public void Set(string key, Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCacheEntry entry, System.TimeSpan validFor) { }
public System.Threading.Tasks.Task SetAsync(string key, Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCacheEntry entry, System.TimeSpan validFor) { throw null; }
}
public partial class ResponseCachingContext
{
internal ResponseCachingContext() { }
public System.TimeSpan? CachedEntryAge { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.ResponseCaching.Internal.CachedVaryByRules CachedVaryByRules { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Http.HttpContext HttpContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.DateTimeOffset? ResponseTime { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public partial class ResponseCachingKeyProvider : Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCachingKeyProvider
{
public ResponseCachingKeyProvider(Microsoft.Extensions.ObjectPool.ObjectPoolProvider poolProvider, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.ResponseCaching.ResponseCachingOptions> options) { }
public string CreateBaseKey(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context) { throw null; }
public System.Collections.Generic.IEnumerable<string> CreateLookupVaryByKeys(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context) { throw null; }
public string CreateStorageVaryByKey(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context) { throw null; }
}
public partial class ResponseCachingPolicyProvider : Microsoft.AspNetCore.ResponseCaching.Internal.IResponseCachingPolicyProvider
{
public ResponseCachingPolicyProvider() { }
public virtual bool AllowCacheLookup(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context) { throw null; }
public virtual bool AllowCacheStorage(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context) { throw null; }
public virtual bool AttemptResponseCaching(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context) { throw null; }
public virtual bool IsCachedEntryFresh(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context) { throw null; }
public virtual bool IsResponseCacheable(Microsoft.AspNetCore.ResponseCaching.Internal.ResponseCachingContext context) { throw null; }
}
}
namespace Microsoft.Extensions.DependencyInjection
{
public static partial class ResponseCachingServicesExtensions

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Extensions.Primitives;

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public class CachedResponse : IResponseCacheEntry
internal class CachedResponse : IResponseCacheEntry
{
public DateTimeOffset Created { get; set; }

View File

@ -1,11 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public class CachedVaryByRules : IResponseCacheEntry
internal class CachedVaryByRules : IResponseCacheEntry
{
public string VaryByKeyPrefix { get; set; }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public interface IResponseCache
internal interface IResponseCache
{
/// <summary>
/// Gets the cached response for the given key, if it exists.

View File

@ -3,7 +3,7 @@
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public interface IResponseCacheEntry
internal interface IResponseCacheEntry
{
}
}

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public interface IResponseCachingKeyProvider
internal interface IResponseCachingKeyProvider
{
/// <summary>
/// Create a base key for a response cache entry.

View File

@ -3,7 +3,7 @@
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public interface IResponseCachingPolicyProvider
internal interface IResponseCachingPolicyProvider
{
/// <summary>
/// Determine whether the response caching logic should be attempted for the incoming HTTP request.

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -7,11 +7,11 @@ using Microsoft.Extensions.Caching.Memory;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public class MemoryResponseCache : IResponseCache
internal class MemoryResponseCache : IResponseCache
{
private readonly IMemoryCache _cache;
public MemoryResponseCache(IMemoryCache cache)
internal MemoryResponseCache(IMemoryCache cache)
{
_cache = cache ?? throw new ArgumentNullException(nameof(cache));
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -10,7 +10,7 @@ using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public class ResponseCachingContext
internal class ResponseCachingContext
{
private DateTimeOffset? _responseDate;
private bool _parsedResponseDate;
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
public TimeSpan? CachedEntryAge { get; internal set; }
public CachedVaryByRules CachedVaryByRules { get; internal set; }
public CachedVaryByRules CachedVaryByRules { get; set; }
internal ILogger Logger { get; }

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -11,7 +11,7 @@ using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public class ResponseCachingKeyProvider : IResponseCachingKeyProvider
internal class ResponseCachingKeyProvider : IResponseCachingKeyProvider
{
// Use the record separator for delimiting components of the cache key to avoid possible collisions
private static readonly char KeyDelimiter = '\x1e';
@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
private readonly ObjectPool<StringBuilder> _builderPool;
private readonly ResponseCachingOptions _options;
public ResponseCachingKeyProvider(ObjectPoolProvider poolProvider, IOptions<ResponseCachingOptions> options)
internal ResponseCachingKeyProvider(ObjectPoolProvider poolProvider, IOptions<ResponseCachingOptions> options)
{
if (poolProvider == null)
{

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -8,7 +8,7 @@ using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.ResponseCaching.Internal
{
public class ResponseCachingPolicyProvider : IResponseCachingPolicyProvider
internal class ResponseCachingPolicyProvider : IResponseCachingPolicyProvider
{
public virtual bool AttemptResponseCaching(ResponseCachingContext context)
{

View File

@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.ResponseCaching.Internal;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ObjectPool;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
@ -30,17 +31,17 @@ namespace Microsoft.AspNetCore.ResponseCaching
RequestDelegate next,
IOptions<ResponseCachingOptions> options,
ILoggerFactory loggerFactory,
IResponseCachingPolicyProvider policyProvider,
IResponseCachingKeyProvider keyProvider)
ObjectPoolProvider poolProvider)
: this(
next,
options,
loggerFactory,
policyProvider,
new ResponseCachingPolicyProvider(),
new MemoryResponseCache(new MemoryCache(new MemoryCacheOptions
{
SizeLimit = options.Value.SizeLimit
})), keyProvider)
})),
new ResponseCachingKeyProvider(poolProvider, options))
{ }
// for testing

View File

@ -27,8 +27,6 @@ namespace Microsoft.Extensions.DependencyInjection
}
services.TryAddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
services.TryAddSingleton<IResponseCachingPolicyProvider, ResponseCachingPolicyProvider>();
services.TryAddSingleton<IResponseCachingKeyProvider, ResponseCachingKeyProvider>();
return services;
}

View File

@ -23,7 +23,7 @@ namespace EchoApp
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{