20 implementations of IOutputCachePolicy
Microsoft.AspNetCore.OutputCaching (18)
Policies\CompositePolicy.cs (1)
9
internal sealed class CompositePolicy :
IOutputCachePolicy
Policies\DefaultPolicy.cs (1)
12
internal sealed class DefaultPolicy :
IOutputCachePolicy
Policies\EmptyPolicy.cs (1)
9
internal sealed class EmptyPolicy :
IOutputCachePolicy
Policies\EnableCachePolicy.cs (1)
9
internal sealed class EnableCachePolicy :
IOutputCachePolicy
Policies\ExpirationPolicy.cs (1)
9
internal sealed class ExpirationPolicy :
IOutputCachePolicy
Policies\LockingPolicy.cs (1)
9
internal sealed class LockingPolicy :
IOutputCachePolicy
Policies\NamedPolicy.cs (1)
12
internal sealed class NamedPolicy :
IOutputCachePolicy
Policies\NoLookupPolicy.cs (1)
9
internal sealed class NoLookupPolicy :
IOutputCachePolicy
Policies\NoStorePolicy.cs (1)
9
internal sealed class NoStorePolicy :
IOutputCachePolicy
Policies\PredicatePolicy.cs (1)
9
internal sealed class PredicatePolicy :
IOutputCachePolicy
Policies\SetCacheKeyPrefixPolicy.cs (1)
11
internal sealed class SetCacheKeyPrefixPolicy :
IOutputCachePolicy
Policies\TagsPolicy.cs (1)
9
internal sealed class TagsPolicy :
IOutputCachePolicy
Policies\TypedPolicy.cs (1)
13
internal sealed class TypedPolicy :
IOutputCachePolicy
Policies\VaryByHeaderPolicy.cs (1)
11
internal sealed class VaryByHeaderPolicy :
IOutputCachePolicy
Policies\VaryByHostPolicy.cs (1)
9
internal sealed class VaryByHostPolicy :
IOutputCachePolicy
Policies\VaryByQueryPolicy.cs (1)
12
internal sealed class VaryByQueryPolicy :
IOutputCachePolicy
Policies\VaryByRouteValuePolicy.cs (1)
11
internal sealed class VaryByRouteValuePolicy :
IOutputCachePolicy
Policies\VaryByValuePolicy.cs (1)
11
internal sealed class VaryByValuePolicy :
IOutputCachePolicy
Microsoft.AspNetCore.OutputCaching.Tests (2)
OutputCacheMiddlewareTests.cs (1)
991
public class RefreshableCachePolicy :
IOutputCachePolicy
TestUtils.cs (1)
385
internal class AllowTestPolicy :
IOutputCachePolicy
173 references to IOutputCachePolicy
Microsoft.AspNetCore.OutputCaching (106)
OutputCacheAttribute.cs (2)
21
private
IOutputCachePolicy
? _builtPolicy;
67
internal
IOutputCachePolicy
BuildPolicy()
OutputCacheMiddleware.cs (11)
92
private async Task InvokeAwaited(HttpContext httpContext, IReadOnlyList<
IOutputCachePolicy
> policies)
101
foreach (
var
policy in policies)
168
foreach (
var
policy in policies)
215
internal bool TryGetRequestPolicies(HttpContext httpContext, out IReadOnlyList<
IOutputCachePolicy
> policies)
217
policies = Array.Empty<
IOutputCachePolicy
>();
218
List<
IOutputCachePolicy
>? result = null;
228
var
policy = metadata?.GetMetadata<
IOutputCachePolicy
>();
253
internal async Task<bool> TryServeCachedResponseAsync(OutputCacheContext context, OutputCacheEntry? cacheEntry, IReadOnlyList<
IOutputCachePolicy
> policies)
265
foreach (
var
policy in policies)
330
internal async Task<bool> TryServeFromCacheAsync(OutputCacheContext cacheContext, IReadOnlyList<
IOutputCachePolicy
> policies)
OutputCacheOptions.cs (12)
39
internal Dictionary<string,
IOutputCachePolicy
>? NamedPolicies { get; set; }
41
internal List<
IOutputCachePolicy
>? BasePolicies { get; set; }
49
/// Defines a <see cref="
IOutputCachePolicy
"/> which can be referenced by name.
53
public void AddPolicy(string name,
IOutputCachePolicy
policy)
55
NamedPolicies ??= new Dictionary<string,
IOutputCachePolicy
>(StringComparer.OrdinalIgnoreCase);
60
/// Defines a <see cref="
IOutputCachePolicy
"/> which can be referenced by name.
68
/// Defines a <see cref="
IOutputCachePolicy
"/> which can be referenced by name.
77
NamedPolicies ??= new Dictionary<string,
IOutputCachePolicy
>(StringComparer.OrdinalIgnoreCase);
82
/// Adds an <see cref="
IOutputCachePolicy
"/> instance to base policies.
85
public void AddBasePolicy(
IOutputCachePolicy
policy)
92
/// Builds and adds an <see cref="
IOutputCachePolicy
"/> instance to base policies.
99
/// Builds and adds an <see cref="
IOutputCachePolicy
"/> instance to base policies.
OutputCachePolicyBuilder.cs (8)
18
private
IOutputCachePolicy
? _builtPolicy;
19
private readonly List<
IOutputCachePolicy
> _policies = new();
35
internal OutputCachePolicyBuilder AddPolicy(
IOutputCachePolicy
policy)
55
public OutputCachePolicyBuilder AddPolicy<[DynamicallyAccessedMembers(ActivatorAccessibility)] T>() where T :
IOutputCachePolicy
312
/// Creates the <see cref="
IOutputCachePolicy
"/>.
314
/// <returns>The<see cref="
IOutputCachePolicy
"/> instance.</returns>
315
internal
IOutputCachePolicy
Build()
322
var
policies = _policies.Count switch
Policies\CompositePolicy.cs (8)
11
private readonly
IOutputCachePolicy
[] _policies;
17
public CompositePolicy(params
IOutputCachePolicy
[] policies)
23
async ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
25
foreach (
var
policy in _policies)
32
async ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
34
foreach (
var
policy in _policies)
41
async ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
43
foreach (
var
policy in _policies)
Policies\DefaultPolicy.cs (3)
21
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
36
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
42
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\EmptyPolicy.cs (4)
11
public static
IOutputCachePolicy
Instance = new EmptyPolicy();
18
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
24
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
30
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\EnableCachePolicy.cs (3)
19
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
27
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
33
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\ExpirationPolicy.cs (3)
23
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
31
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
37
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\LockingPolicy.cs (3)
29
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
37
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
43
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\NamedPolicy.cs (8)
28
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
30
var
policy = GetProfilePolicy(context);
41
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
43
var
policy = GetProfilePolicy(context);
54
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
56
var
policy = GetProfilePolicy(context);
66
internal
IOutputCachePolicy
? GetProfilePolicy(OutputCacheContext context)
78
return policies != null && policies.TryGetValue(_policyName, out
var
cacheProfile)
Policies\NoLookupPolicy.cs (3)
18
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
26
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
32
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\NoStorePolicy.cs (3)
18
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
26
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
32
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\OutputCacheConventionBuilderExtensions.cs (1)
33
public static TBuilder CacheOutput<TBuilder>(this TBuilder builder,
IOutputCachePolicy
policy) where TBuilder : IEndpointConventionBuilder
Policies\PredicatePolicy.cs (7)
14
private readonly
IOutputCachePolicy
_policy;
21
public PredicatePolicy(Func<OutputCacheContext, ValueTask<bool>> asyncPredicate,
IOutputCachePolicy
policy)
28
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
34
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
40
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
45
private ValueTask ExecuteAwaited(Func<
IOutputCachePolicy
, OutputCacheContext, CancellationToken, ValueTask> action,
IOutputCachePolicy
policy, OutputCacheContext context, CancellationToken cancellationToken)
Policies\SetCacheKeyPrefixPolicy.cs (3)
24
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
30
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
36
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\TagsPolicy.cs (3)
23
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
34
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
40
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\TypedPolicy.cs (6)
15
private
IOutputCachePolicy
? _instance;
31
private
IOutputCachePolicy
? CreatePolicy(OutputCacheContext context)
34
return _instance ??= ActivatorUtilities.CreateInstance(options.Value.ApplicationServices, _policyType) as
IOutputCachePolicy
;
38
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
44
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
50
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\VaryByHeaderPolicy.cs (3)
39
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
54
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
60
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\VaryByHostPolicy.cs (3)
25
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
33
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
39
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\VaryByQueryPolicy.cs (3)
40
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
62
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
68
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\VaryByRouteValuePolicy.cs (3)
39
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
46
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
52
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Policies\VaryByValuePolicy.cs (3)
28
ValueTask
IOutputCachePolicy
.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
34
ValueTask
IOutputCachePolicy
.ServeFromCacheAsync(OutputCacheContext context, CancellationToken cancellationToken)
40
ValueTask
IOutputCachePolicy
.ServeResponseAsync(OutputCacheContext context, CancellationToken cancellationToken)
Microsoft.AspNetCore.OutputCaching.Tests (67)
OutputCacheAttributeTests.cs (1)
17
var
policy = attribute.BuildPolicy();
OutputCachePoliciesTests.cs (23)
13
IOutputCachePolicy
policy = DefaultPolicy.Instance;
24
IOutputCachePolicy
policy = DefaultPolicy.Instance;
35
IOutputCachePolicy
policy = DefaultPolicy.Instance;
46
IOutputCachePolicy
policy = DefaultPolicy.Instance;
57
IOutputCachePolicy
policy = EnableCachePolicy.Disabled;
69
IOutputCachePolicy
policy = VaryByHostPolicy.Disabled;
81
IOutputCachePolicy
policy = new ExpirationPolicy(duration);
92
IOutputCachePolicy
policy = LockingPolicy.Enabled;
103
IOutputCachePolicy
policy = LockingPolicy.Disabled;
114
IOutputCachePolicy
policy = NoLookupPolicy.Instance;
125
IOutputCachePolicy
policy = NoStorePolicy.Instance;
140
IOutputCachePolicy
predicate = new PredicatePolicy(c => ValueTask.FromResult(filter), enabled ? EnableCachePolicy.Enabled : EnableCachePolicy.Disabled);
156
IOutputCachePolicy
policy = new NamedPolicy("enabled");
174
IOutputCachePolicy
policy = new TagsPolicy("tag1", "tag2");
187
IOutputCachePolicy
policy = new VaryByHeaderPolicy(Array.Empty<string>());
200
IOutputCachePolicy
policy = new VaryByHeaderPolicy(header);
213
IOutputCachePolicy
policy = new VaryByHeaderPolicy(headers);
225
IOutputCachePolicy
policy = new VaryByQueryPolicy(Array.Empty<string>());
238
IOutputCachePolicy
policy = new VaryByQueryPolicy(query);
251
IOutputCachePolicy
policy = new VaryByQueryPolicy("query1", "query2");
264
IOutputCachePolicy
policy = new VaryByQueryPolicy(queries);
277
IOutputCachePolicy
policy = new SetCacheKeyPrefixPolicy((context, cancellationToken) => ValueTask.FromResult(value));
291
IOutputCachePolicy
policy = new VaryByValuePolicy((context, CancellationToken) => ValueTask.FromResult(new KeyValuePair<string, string>(key, value)));
OutputCachePolicyBuilderTests.cs (26)
15
var
policy = builder.Build();
24
var
policy = builder.Build();
36
var
policy = builder.Expire(TimeSpan.FromSeconds(duration)).Build();
49
var
policy = builder.NoCache().Build();
66
var
policy = builder.AddPolicy(new NamedPolicy(name)).Build();
84
var
policy = builder.AddPolicy(new NamedPolicy(name)).Build();
97
var
policy = builder.SetVaryByHost(false).Build();
111
var
policy = builder.SetVaryByHeader("HeaderA", "HeaderC").Build();
127
var
policy = builder.SetVaryByQuery("QueryA", "QueryC").Build();
147
var
policy = builder.SetVaryByRouteValue("RouteA", "RouteC").Build();
167
var
policy = builder.SetVaryByRouteValue(new string[] { "RouteA", "RouteC" }).Build();
187
var
policy = builder.SetVaryByRouteValue("RouteB").SetVaryByRouteValue("RouteA", "RouteC").Build();
203
var
policy1 = new OutputCachePolicyBuilder().SetCacheKeyPrefix("tenant1").Build();
204
var
policy2 = new OutputCachePolicyBuilder().SetCacheKeyPrefix(context => "tenant2").Build();
205
var
policy3 = new OutputCachePolicyBuilder().SetCacheKeyPrefix((context, cancellationToken) => ValueTask.FromResult("tenant3")).Build();
222
var
policy = builder
242
var
policy = builder.Tag("tag1", "tag2").Build();
256
var
policy = builder.Build();
268
var
policy = builder.SetLocking(true).Build();
280
var
policy = builder.SetLocking(false).Build();
292
var
policy = builder.Build();
307
var
policy = builder.NoCache().Build();
319
var
policy = builder.NoCache().Cache().Build();
339
foreach (
var
policy in options.BasePolicies)
357
foreach (
var
policy in options.BasePolicies)
375
foreach (
var
policy in options.BasePolicies)
OutputCachePolicyProviderTests.cs (17)
51
foreach (
var
policy in policies)
67
var
policy = new OutputCachePolicyBuilder().Build();
84
var
policy = new OutputCachePolicyBuilder().Build();
103
var
policy = new OutputCachePolicyBuilder().Build();
119
var
policy = new OutputCachePolicyBuilder().Build();
132
var
policy = new OutputCachePolicyBuilder().Build();
150
var
policy = new OutputCachePolicyBuilder().Build();
168
var
policy = new OutputCachePolicyBuilder().Build();
186
var
policy = new OutputCachePolicyBuilder().Build();
201
var
policy = new OutputCachePolicyBuilder().Build();
214
var
policy = new OutputCachePolicyBuilder().Build();
232
var
policy = new OutputCachePolicyBuilder().Build();
248
var
policy = new OutputCachePolicyBuilder().Build();
324
var
policy = new OutputCachePolicyBuilder().Build();
342
var
policy = new OutputCachePolicyBuilder().Build();
365
var
policy = new OutputCachePolicyBuilder().Build();
388
var
policy = new OutputCachePolicyBuilder().Build();