File tree 2 files changed +13
-14
lines changed
src/Middleware/Microsoft.AspNetCore.OutputCaching.StackExchangeRedis
2 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.OutputCaching.StackExchangeRedis;
13
13
/// <summary>
14
14
/// Configuration options for Redis based output cache.
15
15
/// </summary>
16
- public sealed class RedisOutputCacheOptions : IOptions < RedisOutputCacheOptions >
16
+ public sealed class RedisOutputCacheOptions
17
17
{
18
18
/// <summary>
19
19
/// The configuration used to connect to Redis.
@@ -42,11 +42,6 @@ public sealed class RedisOutputCacheOptions : IOptions<RedisOutputCacheOptions>
42
42
/// </summary>
43
43
public Func < ProfilingSession > ? ProfilingSession { get ; set ; }
44
44
45
- RedisOutputCacheOptions IOptions < RedisOutputCacheOptions > . Value
46
- {
47
- get { return this ; }
48
- }
49
-
50
45
private bool ? _useForceReconnect ;
51
46
internal bool UseForceReconnect
52
47
{
Original file line number Diff line number Diff line change 3
3
4
4
using System . Buffers ;
5
5
using System . IO . Pipelines ;
6
+ using Microsoft . Extensions . DependencyInjection ;
6
7
using StackExchange . Redis ;
7
8
using Xunit . Abstractions ;
8
9
@@ -20,16 +21,19 @@ public class OutputCacheGetSetTests : IClassFixture<RedisConnectionFixture>
20
21
21
22
public OutputCacheGetSetTests ( RedisConnectionFixture connection , ITestOutputHelper log )
22
23
{
24
+ // use DI to get the configured service, but tweak the GC mode
23
25
_fixture = connection ;
24
- _cache = new RedisOutputCacheStore ( new RedisOutputCacheOptions
25
- {
26
- ConnectionMultiplexerFactory = ( ) => Task . FromResult ( _fixture . Connection ) ,
27
- InstanceName = "TestPrefix" ,
28
- } )
29
- {
30
- GarbageCollectionEnabled = false ,
31
- } ;
32
26
Log = log ;
27
+ var services = new ServiceCollection ( ) ;
28
+ services . AddStackExchangeRedisOutputCache ( options => {
29
+ options . ConnectionMultiplexerFactory = ( ) => Task . FromResult ( _fixture . Connection ) ;
30
+ options . InstanceName = "TestPrefix" ;
31
+ } ) ;
32
+ var svc = Assert . IsAssignableFrom < RedisOutputCacheStore > (
33
+ services . BuildServiceProvider ( ) . GetService < IOutputCacheStore > ( ) ) ;
34
+ Assert . NotNull ( svc ) ;
35
+ svc . GarbageCollectionEnabled = false ;
36
+ _cache = svc ;
33
37
}
34
38
35
39
#if DEBUG
You can’t perform that action at this time.
0 commit comments