-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds Caching * Adds Caching Project * Adds ExpirationTime to Cache Configuration * Adds Caching Interfaces * Adds Cache infra on Dockerfile * Adds FinancialHub.Core.Infra.IntegrationTests project * Adds FinancialHubInfraFixture and FinancialHubInfraSetup * Adds FinancialHubBuilderSetup and FinancialHubSetup * Adds appsettings and appsettings.Testing * Changes Models private set to init * Changes Application Mappers, Services e Validators concrete classes as internal * Changes Infra Data and Caching concrete classes as internal
- Loading branch information
1 parent
f641f0b
commit b1c501c
Showing
108 changed files
with
1,799 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/api/core/FinancialHub.Core.Domain/Interfaces/Caching/IAccountsCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using FinancialHub.Core.Domain.Models; | ||
|
||
namespace FinancialHub.Core.Domain.Interfaces.Caching | ||
{ | ||
public interface IAccountsCache | ||
{ | ||
Task AddAsync(AccountModel account); | ||
Task<AccountModel?> GetAsync(Guid id); | ||
Task RemoveAsync(Guid id); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/api/core/FinancialHub.Core.Domain/Interfaces/Caching/IBalancesCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using FinancialHub.Core.Domain.Models; | ||
|
||
namespace FinancialHub.Core.Domain.Interfaces.Caching | ||
{ | ||
public interface IBalancesCache | ||
{ | ||
Task AddAsync(BalanceModel balance); | ||
Task AddAsync(IEnumerable<BalanceModel> balances); | ||
Task<ICollection<BalanceModel>> GetByAccountAsync(Guid accountId); | ||
Task<BalanceModel?> GetAsync(Guid id); | ||
Task RemoveAsync(Guid id); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/api/core/FinancialHub.Core.Domain/Interfaces/Caching/ICategoriesCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using FinancialHub.Core.Domain.Models; | ||
|
||
namespace FinancialHub.Core.Domain.Interfaces.Caching | ||
{ | ||
public interface ICategoriesCache | ||
{ | ||
Task AddAsync(CategoryModel category); | ||
Task<CategoryModel?> GetAsync(Guid id); | ||
Task RemoveAsync(Guid id); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/api/core/FinancialHub.Core.Domain/Interfaces/Caching/ITransactionsCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using FinancialHub.Core.Domain.Filters; | ||
using FinancialHub.Core.Domain.Models; | ||
|
||
namespace FinancialHub.Core.Domain.Interfaces.Caching | ||
{ | ||
[Obsolete("No use for it. Filters are too complex to use cache")] | ||
Check warning on line 6 in src/api/core/FinancialHub.Core.Domain/Interfaces/Caching/ITransactionsCache.cs
|
||
public interface ITransactionsCache | ||
{ | ||
Task AddAsync(TransactionModel transaction); | ||
Task<ICollection<TransactionModel>> GetAsync(params Guid[] balances); | ||
Task<ICollection<TransactionModel>> GetAsync(TransactionFilter filter); | ||
Task RemoveAsync(Guid id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/api/core/FinancialHub.Core.Infra.Caching/Configurations/CacheConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace FinancialHub.Core.Infra.Caching.Configurations | ||
{ | ||
internal class CacheConfiguration | ||
{ | ||
public const string Cache = "Cache"; | ||
|
||
public int ExpirationTime { get; set; } | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...FinancialHub.Core.Infra.Caching/Extensions/Configurations/IServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using FinancialHub.Core.Infra.Caching.Repositories; | ||
using FinancialHub.Core.Infra.Caching.Configurations; | ||
|
||
namespace FinancialHub.Core.Infra.Caching.Extensions.Configurations | ||
{ | ||
public static class IServiceCollectionExtensions | ||
{ | ||
public static IServiceCollection AddCaching(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services | ||
.AddCachingConfiguration(configuration) | ||
.AddRedisCaching(configuration) | ||
.AddCachingServices(); | ||
|
||
return services; | ||
} | ||
|
||
private static IServiceCollection AddRedisCaching(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddStackExchangeRedisCache((options) => | ||
{ | ||
options.Configuration = configuration.GetConnectionString("cache"); | ||
}); | ||
|
||
return services; | ||
} | ||
|
||
private static IServiceCollection AddCachingServices(this IServiceCollection services) | ||
{ | ||
services.AddScoped<IAccountsCache, AccountsCache>(); | ||
services.AddScoped<IBalancesCache, BalancesCache>(); | ||
services.AddScoped<ICategoriesCache, CategoriesCache>(); | ||
return services; | ||
} | ||
|
||
private static IServiceCollection AddCachingConfiguration(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddOptions(); | ||
services.Configure<CacheConfiguration>(options => | ||
{ | ||
options.ExpirationTime = int.Parse(configuration["Cache:ExpirationTime"]); | ||
}); | ||
return services; | ||
} | ||
} | ||
} |
Oops, something went wrong.