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

Commit 2eb66dc

Browse files
committed
Merge branch 'rel/1.0.0' into rel/1.0.0-preview1
2 parents cfa62bb + 8acf714 commit 2eb66dc

25 files changed

+474
-444
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
}
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;
@@ -55,7 +55,7 @@ public virtual bool IsRequestCacheable(ResponseCacheContext context)
5555
return true;
5656
}
5757

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

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

src/Microsoft.AspNetCore.ResponseCaching/Internal/SendFileFeatureWrapper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ namespace Microsoft.AspNetCore.ResponseCaching.Internal
1010
internal class SendFileFeatureWrapper : IHttpSendFileFeature
1111
{
1212
private readonly IHttpSendFileFeature _originalSendFileFeature;
13-
private readonly ResponseCacheStream _responseCacheStream;
13+
private readonly ResponseCachingStream _responseCachingStream;
1414

15-
public SendFileFeatureWrapper(IHttpSendFileFeature originalSendFileFeature, ResponseCacheStream responseCacheStream)
15+
public SendFileFeatureWrapper(IHttpSendFileFeature originalSendFileFeature, ResponseCachingStream responseCachingStream)
1616
{
1717
_originalSendFileFeature = originalSendFileFeature;
18-
_responseCacheStream = responseCacheStream;
18+
_responseCachingStream = responseCachingStream;
1919
}
2020

2121
// Flush and disable the buffer if anyone tries to call the SendFile feature.
2222
public Task SendFileAsync(string path, long offset, long? length, CancellationToken cancellation)
2323
{
24-
_responseCacheStream.DisableBuffering();
24+
_responseCachingStream.DisableBuffering();
2525
return _originalSendFileFeature.SendFileAsync(path, offset, length, cancellation);
2626
}
2727
}

0 commit comments

Comments
 (0)