@@ -24,8 +24,7 @@ public static class EFServiceProvider
2424 /// </summary>
2525 public static IServiceProvider Instance { get ; } = _serviceProviderBuilder . Value ;
2626
27- public static T GetRequiredService < T > ( )
28- => Instance . GetRequiredService < T > ( ) ;
27+ public static T GetRequiredService < T > ( ) => Instance . GetRequiredService < T > ( ) ;
2928
3029 public static void RunInContext ( Action < ApplicationDbContext > action )
3130 {
@@ -52,13 +51,14 @@ private static IServiceProvider getServiceProvider()
5251 Console . WriteLine ( $ "Using `{ basePath } ` as the ContentRootPath") ;
5352
5453 var configuration = new ConfigurationBuilder ( ) . SetBasePath ( basePath )
55- . AddJsonFile ( "appsettings.json" , false , true ) . Build ( ) ;
54+ . AddJsonFile ( path : "appsettings.json" , optional : false , reloadOnChange : true )
55+ . Build ( ) ;
5656
5757 services . AddSingleton ( _ => configuration ) ;
5858
5959 services . AddEFSecondLevelCache ( options
60- => options . UseMemoryCacheProvider ( CacheExpirationMode . Absolute , TimeSpan . FromMinutes ( 5 ) )
61- . ConfigureLogging ( true )
60+ => options . UseMemoryCacheProvider ( CacheExpirationMode . Absolute , TimeSpan . FromMinutes ( minutes : 5 ) )
61+ . ConfigureLogging ( enable : true )
6262
6363 //options.UseCacheManagerCoreProvider()
6464 ) ;
@@ -81,12 +81,12 @@ public static string GetConnectionString(string basePath, IConfigurationRoot con
8181 "\\ Issues\\ "
8282 } , StringSplitOptions . RemoveEmptyEntries ) [ 0 ] ;
8383
84- var contentRootPath = Path . Combine ( testsFolder , "Issues" , "Issue9SQLiteInt32" ) ;
85- var connectionString = configuration [ "ConnectionStrings:ApplicationDbContextConnection" ] ;
84+ var contentRootPath = Path . Combine ( testsFolder , path2 : "Issues" , path3 : "Issue9SQLiteInt32" ) ;
85+ var connectionString = configuration [ key : "ConnectionStrings:ApplicationDbContextConnection" ] ;
8686
87- if ( connectionString . Contains ( "%CONTENTROOTPATH%" ) )
87+ if ( connectionString . Contains ( value : "%CONTENTROOTPATH%" ) )
8888 {
89- connectionString = connectionString . Replace ( "%CONTENTROOTPATH%" , contentRootPath ) ;
89+ connectionString = connectionString . Replace ( oldValue : "%CONTENTROOTPATH%" , contentRootPath ) ;
9090 }
9191
9292 Console . WriteLine ( $ "Using { connectionString } ") ;
@@ -105,18 +105,25 @@ private static void addCacheManagerCoreRedis(ServiceCollection services)
105105
106106 const string redisConfigurationKey = "redis" ;
107107
108- services . AddSingleton ( typeof ( ICacheManagerConfiguration ) , new CacheManager . Core . ConfigurationBuilder ( )
109- . WithJsonSerializer ( jss , jss ) . WithUpdateMode ( CacheUpdateMode . Up ) . WithRedisConfiguration (
110- redisConfigurationKey , config =>
111- {
112- config . WithAllowAdmin ( ) . WithDatabase ( 0 ) . WithEndpoint ( "localhost" , 6379 )
113-
114- // Enables keyspace notifications to react on eviction/expiration of items.
115- // Make sure that all servers are configured correctly and 'notify-keyspace-events' is at least set to 'Exe', otherwise CacheManager will not retrieve any events.
116- // See https://redis.io/topics/notifications#configuration for configuration details.
117- . EnableKeyspaceEvents ( ) ;
118- } ) . WithMaxRetries ( 100 ) . WithRetryTimeout ( 50 ) . WithRedisCacheHandle ( redisConfigurationKey )
119- . DisablePerformanceCounters ( ) . DisableStatistics ( ) . Build ( ) ) ;
108+ services . AddSingleton ( typeof ( ICacheManagerConfiguration ) , new CacheConfigurationBuilder ( )
109+ . WithJsonSerializer ( jss , jss )
110+ . WithUpdateMode ( CacheUpdateMode . Up )
111+ . WithRedisConfiguration ( redisConfigurationKey , config =>
112+ {
113+ config . WithAllowAdmin ( )
114+ . WithDatabase ( databaseIndex : 0 )
115+ . WithEndpoint ( host : "localhost" , port : 6379 )
116+
117+ // Enables keyspace notifications to react on eviction/expiration of items.
118+ // Make sure that all servers are configured correctly and 'notify-keyspace-events' is at least set to 'Exe', otherwise CacheManager will not retrieve any events.
119+ // See https://redis.io/topics/notifications#configuration for configuration details.
120+ . EnableKeyspaceEvents ( ) ;
121+ } )
122+ . WithMaxRetries ( retries : 100 )
123+ . WithRetryTimeout ( timeoutMillis : 50 )
124+ . WithRedisCacheHandle ( redisConfigurationKey )
125+ . DisableStatistics ( )
126+ . Build ( ) ) ;
120127
121128 services . AddSingleton ( typeof ( ICacheManager < > ) , typeof ( BaseCacheManager < > ) ) ;
122129 }
0 commit comments