-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03796a8
commit b4924c0
Showing
3 changed files
with
41 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Domain.Pkg.Entities; | ||
using OpenAdm.Domain.Interfaces; | ||
using OpenAdm.Infra.Cached.Interfaces; | ||
using OpenAdm.Infra.Repositories; | ||
|
||
namespace OpenAdm.Infra.Cached.Cached; | ||
|
||
public sealed class ConfiguracaoParceiroCached : IConfiguracaoParceiroRepository | ||
{ | ||
private readonly ConfiguracaoParceiroRepository _configuracaoParceiroRepository; | ||
private readonly ICachedService<ConfiguracaoParceiro> _cachedService; | ||
|
||
public ConfiguracaoParceiroCached( | ||
ConfiguracaoParceiroRepository configuracaoParceiroRepository, | ||
ICachedService<ConfiguracaoParceiro> cachedService) | ||
{ | ||
_configuracaoParceiroRepository = configuracaoParceiroRepository; | ||
_cachedService = cachedService; | ||
} | ||
|
||
public async Task<ConfiguracaoParceiro?> GetParceiroByDominioAdmAsync(string dominio) | ||
{ | ||
var configuracaoParceiro = await _cachedService.GetItemAsync(dominio); | ||
|
||
if(configuracaoParceiro == null) | ||
{ | ||
configuracaoParceiro = await _configuracaoParceiroRepository.GetParceiroByDominioAdmAsync(dominio); | ||
if(configuracaoParceiro != null) | ||
{ | ||
await _cachedService.SetItemAsync(dominio, configuracaoParceiro); | ||
} | ||
} | ||
|
||
return configuracaoParceiro; | ||
} | ||
} |
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