Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit 8acf714

Browse files
committed
API review feedback
Rename middleware components ResponseCache => ResponseCaching Move ResponseCachingOptions to Microsoft.AspNetCore.ResponseCaching namespace Rename extension methods
1 parent 151ac2c commit 8acf714

26 files changed

+480
-448
lines changed

samples/ResponseCachingSample/Startup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public class Startup
1515
{
1616
public void ConfigureServices(IServiceCollection services)
1717
{
18-
services.AddMemoryResponseCacheStore();
18+
services.AddResponseCaching();
1919
}
2020

2121
public void Configure(IApplicationBuilder app)
2222
{
23-
app.UseResponseCache();
23+
app.UseResponseCaching();
2424
app.Run(async (context) =>
2525
{
2626
context.Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue()
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using Microsoft.Extensions.Primitives;
5-
64
namespace Microsoft.AspNetCore.ResponseCaching
75
{
86
/// <summary>
97
/// A feature for configuring additional response cache options on the HTTP response.
108
/// </summary>
11-
public interface IResponseCacheFeature
9+
public interface IResponseCachingFeature
1210
{
1311
/// <summary>
1412
/// Gets or sets the query keys used by the response cache middleware for calculating secondary vary keys.
1513
/// </summary>
16-
StringValues VaryByQueryKeys { get; set; }
14+
string[] VaryByQueryKeys { get; set; }
1715
}
1816
}

src/Microsoft.AspNetCore.ResponseCaching.Abstractions/project.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
"caching"
1818
]
1919
},
20-
"dependencies": {
21-
"Microsoft.Extensions.Primitives": "1.0.0"
22-
},
2320
"frameworks": {
2421
"net451": {},
25-
"netstandard1.3": {}
22+
"netstandard1.3": {
23+
"dependencies": {
24+
"System.Runtime": "4.1.0",
25+
"System.Resources.ResourceManager": "4.0.1"
26+
}
27+
}
2628
}
2729
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Microsoft.AspNetCore.ResponseCaching.Internal
88
{
9-
public interface IResponseCacheStore
9+
public interface IResponseCache
1010
{
1111
Task<IResponseCacheEntry> GetAsync(string key);
1212
Task SetAsync(string key, IResponseCacheEntry entry, TimeSpan validFor);

src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCacheKeyProvider.cs renamed to src/Microsoft.AspNetCore.ResponseCaching/Internal/Interfaces/IResponseCachingKeyProvider.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55

66
namespace Microsoft.AspNetCore.ResponseCaching.Internal
77
{
8-
public interface IResponseCacheKeyProvider
8+
public interface IResponseCachingKeyProvider
99
{
1010
/// <summary>
1111
/// Create a base key for a response cache entry.
1212
/// </summary>
13-
/// <param name="context">The <see cref="ResponseCacheContext"/>.</param>
13+
/// <param name="context">The <see cref="ResponseCachingContext"/>.</param>
1414
/// <returns>The created base key.</returns>
15-
string CreateBaseKey(ResponseCacheContext context);
15+
string CreateBaseKey(ResponseCachingContext context);
1616

1717
/// <summary>
1818
/// Create a vary key for storing cached responses.
1919
/// </summary>
20-
/// <param name="context">The <see cref="ResponseCacheContext"/>.</param>
20+
/// <param name="context">The <see cref="ResponseCachingContext"/>.</param>
2121
/// <returns>The created vary key.</returns>
22-
string CreateStorageVaryByKey(ResponseCacheContext context);
22+
string CreateStorageVaryByKey(ResponseCachingContext context);
2323

2424
/// <summary>
2525
/// Create one or more vary keys for looking up cached responses.
2626
/// </summary>
27-
/// <param name="context">The <see cref="ResponseCacheContext"/>.</param>
27+
/// <param name="context">The <see cref="ResponseCachingContext"/>.</param>
2828
/// <returns>An ordered <see cref="IEnumerable{T}"/> containing the vary keys to try when looking up items.</returns>
29-
IEnumerable<string> CreateLookupVaryByKeys(ResponseCacheContext context);
29+
IEnumerable<string> CreateLookupVaryByKeys(ResponseCachingContext context);
3030
}
3131
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33

44
namespace Microsoft.AspNetCore.ResponseCaching.Internal
55
{
6-
public interface IResponseCachePolicyProvider
6+
public interface IResponseCachingPolicyProvider
77
{
88
/// <summary>
99
/// Determine wehther the response cache middleware should be executed for the incoming HTTP request.
1010
/// </summary>
11-
/// <param name="context">The <see cref="ResponseCacheContext"/>.</param>
11+
/// <param name="context">The <see cref="ResponseCachingContext"/>.</param>
1212
/// <returns><c>true</c> if the request is cacheable; otherwise <c>false</c>.</returns>
13-
bool IsRequestCacheable(ResponseCacheContext context);
13+
bool IsRequestCacheable(ResponseCachingContext context);
1414

1515
/// <summary>
1616
/// Determine whether the response received by the middleware be cached for future requests.
1717
/// </summary>
18-
/// <param name="context">The <see cref="ResponseCacheContext"/>.</param>
18+
/// <param name="context">The <see cref="ResponseCachingContext"/>.</param>
1919
/// <returns><c>true</c> if the response is cacheable; otherwise <c>false</c>.</returns>
20-
bool IsResponseCacheable(ResponseCacheContext context);
20+
bool IsResponseCacheable(ResponseCachingContext context);
2121

2222
/// <summary>
2323
/// Determine whether the response retrieved from the response cache is fresh and be served.
2424
/// </summary>
25-
/// <param name="context">The <see cref="ResponseCacheContext"/>.</param>
25+
/// <param name="context">The <see cref="ResponseCachingContext"/>.</param>
2626
/// <returns><c>true</c> if the cached entry is fresh; otherwise <c>false</c>.</returns>
27-
bool IsCachedEntryFresh(ResponseCacheContext context);
27+
bool IsCachedEntryFresh(ResponseCachingContext context);
2828
}
2929
}

src/Microsoft.AspNetCore.ResponseCaching/Internal/MemoryResponseCacheStore.cs renamed to src/Microsoft.AspNetCore.ResponseCaching/Internal/MemoryResponseCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
namespace Microsoft.AspNetCore.ResponseCaching.Internal
99
{
10-
public class MemoryResponseCacheStore : IResponseCacheStore
10+
public class MemoryResponseCache : IResponseCache
1111
{
1212
private readonly IMemoryCache _cache;
1313

14-
public MemoryResponseCacheStore(IMemoryCache cache)
14+
public MemoryResponseCache(IMemoryCache cache)
1515
{
1616
if (cache == null)
1717
{

src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCacheContext.cs renamed to src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Microsoft.AspNetCore.ResponseCaching.Internal
1313
{
14-
public class ResponseCacheContext
14+
public class ResponseCachingContext
1515
{
1616
private static readonly CacheControlHeaderValue EmptyCacheControl = new CacheControlHeaderValue();
1717

@@ -24,7 +24,7 @@ public class ResponseCacheContext
2424
private DateTimeOffset? _responseExpires;
2525
private bool _parsedResponseExpires;
2626

27-
internal ResponseCacheContext(HttpContext httpContext, ILogger logger)
27+
internal ResponseCachingContext(HttpContext httpContext, ILogger logger)
2828
{
2929
HttpContext = httpContext;
3030
Logger = logger;
@@ -54,7 +54,7 @@ internal ResponseCacheContext(HttpContext httpContext, ILogger logger)
5454

5555
internal Stream OriginalResponseStream { get; set; }
5656

57-
internal ResponseCacheStream ResponseCacheStream { get; set; }
57+
internal ResponseCachingStream ResponseCachingStream { get; set; }
5858

5959
internal IHttpSendFileFeature OriginalSendFileFeature { get; set; }
6060

src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCacheKeyProvider.cs renamed to src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingKeyProvider.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using System.Text;
8-
using Microsoft.AspNetCore.Builder;
9-
using Microsoft.AspNetCore.ResponseCaching.Internal;
108
using Microsoft.Extensions.ObjectPool;
119
using Microsoft.Extensions.Options;
1210
using Microsoft.Extensions.Primitives;
1311

1412
namespace Microsoft.AspNetCore.ResponseCaching.Internal
1513
{
16-
public class ResponseCacheKeyProvider : IResponseCacheKeyProvider
14+
public class ResponseCachingKeyProvider : IResponseCachingKeyProvider
1715
{
1816
// Use the record separator for delimiting components of the cache key to avoid possible collisions
1917
private static readonly char KeyDelimiter = '\x1e';
2018

2119
private readonly ObjectPool<StringBuilder> _builderPool;
22-
private readonly ResponseCacheOptions _options;
20+
private readonly ResponseCachingOptions _options;
2321

24-
public ResponseCacheKeyProvider(ObjectPoolProvider poolProvider, IOptions<ResponseCacheOptions> options)
22+
public ResponseCachingKeyProvider(ObjectPoolProvider poolProvider, IOptions<ResponseCachingOptions> options)
2523
{
2624
if (poolProvider == null)
2725
{
@@ -36,13 +34,13 @@ public ResponseCacheKeyProvider(ObjectPoolProvider poolProvider, IOptions<Respon
3634
_options = options.Value;
3735
}
3836

39-
public IEnumerable<string> CreateLookupVaryByKeys(ResponseCacheContext context)
37+
public IEnumerable<string> CreateLookupVaryByKeys(ResponseCachingContext context)
4038
{
4139
return new string[] { CreateStorageVaryByKey(context) };
4240
}
4341

4442
// GET<delimiter>/PATH
45-
public string CreateBaseKey(ResponseCacheContext context)
43+
public string CreateBaseKey(ResponseCachingContext context)
4644
{
4745
if (context == null)
4846
{
@@ -76,7 +74,7 @@ public string CreateBaseKey(ResponseCacheContext context)
7674
}
7775

7876
// BaseKey<delimiter>H<delimiter>HeaderName=HeaderValue<delimiter>Q<delimiter>QueryName=QueryValue
79-
public string CreateStorageVaryByKey(ResponseCacheContext context)
77+
public string CreateStorageVaryByKey(ResponseCachingContext context)
8078
{
8179
if (context == null)
8280
{
@@ -86,7 +84,7 @@ public string CreateStorageVaryByKey(ResponseCacheContext context)
8684
var varyByRules = context.CachedVaryByRules;
8785
if (varyByRules == null)
8886
{
89-
throw new InvalidOperationException($"{nameof(CachedVaryByRules)} must not be null on the {nameof(ResponseCacheContext)}");
87+
throw new InvalidOperationException($"{nameof(CachedVaryByRules)} must not be null on the {nameof(ResponseCachingContext)}");
9088
}
9189

9290
if ((StringValues.IsNullOrEmpty(varyByRules.Headers) && StringValues.IsNullOrEmpty(varyByRules.QueryKeys)))

src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachePolicyProvider.cs renamed to src/Microsoft.AspNetCore.ResponseCaching/Internal/ResponseCachingPolicyProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
namespace Microsoft.AspNetCore.ResponseCaching.Internal
1010
{
11-
public class ResponseCachePolicyProvider : IResponseCachePolicyProvider
11+
public class ResponseCachingPolicyProvider : IResponseCachingPolicyProvider
1212
{
1313
private static readonly CacheControlHeaderValue EmptyCacheControl = new CacheControlHeaderValue();
1414

15-
public virtual bool IsRequestCacheable(ResponseCacheContext context)
15+
public virtual bool IsRequestCacheable(ResponseCachingContext context)
1616
{
1717
// Verify the method
1818
var request = context.HttpContext.Request;
@@ -56,7 +56,7 @@ public virtual bool IsRequestCacheable(ResponseCacheContext context)
5656
return true;
5757
}
5858

59-
public virtual bool IsResponseCacheable(ResponseCacheContext context)
59+
public virtual bool IsResponseCacheable(ResponseCachingContext context)
6060
{
6161
// Only cache pages explicitly marked with public
6262
if (!context.ResponseCacheControlHeaderValue.Public)
@@ -156,7 +156,7 @@ public virtual bool IsResponseCacheable(ResponseCacheContext context)
156156
return true;
157157
}
158158

159-
public virtual bool IsCachedEntryFresh(ResponseCacheContext context)
159+
public virtual bool IsCachedEntryFresh(ResponseCachingContext context)
160160
{
161161
var age = context.CachedEntryAge.Value;
162162
var cachedControlHeaders = context.CachedResponseHeaders.CacheControl ?? EmptyCacheControl;

0 commit comments

Comments
 (0)