Shared.Infra.Core
1.3.3
dotnet add package Shared.Infra.Core --version 1.3.3
NuGet\Install-Package Shared.Infra.Core -Version 1.3.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shared.Infra.Core" Version="1.3.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shared.Infra.Core" Version="1.3.3" />
<PackageReference Include="Shared.Infra.Core" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Shared.Infra.Core --version 1.3.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Shared.Infra.Core, 1.3.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Shared.Infra.Core@1.3.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Shared.Infra.Core&version=1.3.3
#tool nuget:?package=Shared.Infra.Core&version=1.3.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Shared.Infra.Core — Consul KV com cache (TTL)
Leitura sob demanda do Consul KV com cache em memória.
Sem updater, sem setters: ao chamar GetKeyAsync, lê do cache; se ausente/expirado, busca no Consul, salva com TTL e retorna.
Registro (DI)
// Startup/Program
services.AddConsulConfiguration(
consulUrl: "http://consul:8500/v1/kv", // precisa incluir /v1/kv
consulToken: Environment.GetEnvironmentVariable("CONSUL_TOKEN"),
cacheDuration: TimeSpan.FromMinutes(5) // TTL do cache
);
Uso
var consul = provider.GetRequiredService<IConsulService>();
// Retorna string ou null (se chave não existir)
var valor = await consul.GetKeyAsync("meu/sistema/base-url", ct);
// Em chamadas subsequentes dentro do TTL, retorna do cache.
// Após expirar, reconsulta o Consul e renova o TTL.
Comportamento
- TTL (Time To Live): define por quanto tempo o valor fica válido no cache
(configurado via
cacheDuration). - Erros:
- Chave inexistente →
null. - Falhas HTTP/transientes → tentativas com backoff; ao final, loga erro e retorna
null.
- Chave inexistente →
- Thread-safe: usa
IMemoryCache(concorrente) para armazenar as chaves.
O que foi removido
- Atualizações em background (Hosted Service / updater).
- “Setters”/normalizers e métodos auxiliares (JSON, invalidate, TTL dinâmico).
Requisitos
- .NET com
Microsoft.Extensions.Caching.MemoryeIHttpClientFactory. consulUrlapontando para o endpoint KV (ex.:http://host:8500/v1/kv).- (Opcional)
CONSUL_TOKENpara Consul protegido por ACL.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Http (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.Extensions.Http (>= 8.0.1)
- Polly (>= 8.4.2)
- System.Text.Json (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.3 | 148 | 12/12/2025 |
| 1.3.2 | 143 | 12/12/2025 |
| 1.3.1 | 439 | 12/11/2025 |
| 1.3.0 | 214 | 12/3/2025 |
| 1.2.1 | 402 | 11/13/2025 |
| 1.2.0 | 305 | 11/13/2025 |
| 1.1.5 | 301 | 11/12/2025 |
| 1.1.4 | 300 | 11/12/2025 |
| 1.1.3 | 297 | 11/12/2025 |
| 1.1.2 | 305 | 11/11/2025 |
| 1.1.1 | 304 | 11/10/2025 |
| 1.1.0 | 149 | 11/7/2025 |
| 1.0.9 | 236 | 11/5/2025 |
| 1.0.8 | 232 | 11/3/2025 |
| 1.0.7 | 246 | 10/30/2025 |
| 1.0.6 | 220 | 10/29/2025 |
| 1.0.5 | 227 | 10/27/2025 |
| 1.0.4 | 173 | 10/24/2025 |
| 1.0.3 | 206 | 10/23/2025 |
| 1.0.2 | 221 | 10/23/2025 |
Loading failed