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