diff --git a/src/Nebula.Caching.InMemory/Extensions/InMemoryExtensions/InMemoryExtensions.cs b/src/Nebula.Caching.InMemory/Extensions/InMemoryExtensions/InMemoryExtensions.cs index 92aa885..7971cf8 100644 --- a/src/Nebula.Caching.InMemory/Extensions/InMemoryExtensions/InMemoryExtensions.cs +++ b/src/Nebula.Caching.InMemory/Extensions/InMemoryExtensions/InMemoryExtensions.cs @@ -9,9 +9,29 @@ public static class InMemoryExtensions { public static IServiceCollection AddInMemoryExtensions(this IServiceCollection services, InMemoryConfigurations inMemoryConfigs) { - CreateDefaultInMemoryConfigurationsIfNull(inMemoryConfigs); - SetDefaultValuesBasedOnInMemoryConfigurations(inMemoryConfigs); - InjectInMemoryOptionsObject(services, inMemoryConfigs); + // CreateDefaultInMemoryConfigurationsIfNull(inMemoryConfigs); + // SetDefaultValuesBasedOnInMemoryConfigurations(inMemoryConfigs); + // InjectInMemoryOptionsObject(services, inMemoryConfigs); + + if (inMemoryConfigs is null) + { + inMemoryConfigs = new InMemoryConfigurations + { + ConfigurationSection = "InMemory" + }; + } + + CacheDurationConstants.DefaultCacheDurationInSeconds = inMemoryConfigs.DefaultCacheDurationInSeconds; + + CacheConfigurationConstants.ConfigurationSection = inMemoryConfigs.ConfigurationSection; + + services.AddSingleton(ctx => + { + var configuration = ctx.GetService(); + var inMemoryOptions = configuration.GetSection(inMemoryConfigs.ConfigurationSection).Get(); + inMemoryOptions.ConfigurationRoot = inMemoryConfigs.ConfigurationSection; + return inMemoryOptions; + }); return services; } diff --git a/src/Nebula.Caching.InMemory/Nebula.Caching.InMemory.csproj b/src/Nebula.Caching.InMemory/Nebula.Caching.InMemory.csproj index 993ad54..693fc55 100644 --- a/src/Nebula.Caching.InMemory/Nebula.Caching.InMemory.csproj +++ b/src/Nebula.Caching.InMemory/Nebula.Caching.InMemory.csproj @@ -5,7 +5,7 @@ enable enable Nebula-Caching-InMemory - 1.0.0 + 1.0.1 Rafael Camara Nebula Software Systems Make your dotnet core apps shine by using caching without cluttering your projects.