Skip to content

Commit

Permalink
Merge pull request #4 from Nebula-Software-Systems/feature/add_in_mem…
Browse files Browse the repository at this point in the history
…ory_caching

Fix bug with null references.
  • Loading branch information
RafaelJCamara authored Jun 29, 2023
2 parents fa62aad + bbea098 commit 76116e2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<InMemoryOptions>(ctx =>
{
var configuration = ctx.GetService<IConfiguration>();
var inMemoryOptions = configuration.GetSection(inMemoryConfigs.ConfigurationSection).Get<InMemoryOptions>();
inMemoryOptions.ConfigurationRoot = inMemoryConfigs.ConfigurationSection;
return inMemoryOptions;
});

return services;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Nebula.Caching.InMemory/Nebula.Caching.InMemory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>Nebula-Caching-InMemory</PackageId>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Authors>Rafael Camara</Authors>
<Company>Nebula Software Systems</Company>
<PackageDescription>Make your dotnet core apps shine by using caching without cluttering your projects.</PackageDescription>
Expand Down

0 comments on commit 76116e2

Please sign in to comment.