DevKit.ExecutionEngine.Redis
2026.3.6
dotnet add package DevKit.ExecutionEngine.Redis --version 2026.3.6
NuGet\Install-Package DevKit.ExecutionEngine.Redis -Version 2026.3.6
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="DevKit.ExecutionEngine.Redis" Version="2026.3.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevKit.ExecutionEngine.Redis" Version="2026.3.6" />
<PackageReference Include="DevKit.ExecutionEngine.Redis" />
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 DevKit.ExecutionEngine.Redis --version 2026.3.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DevKit.ExecutionEngine.Redis, 2026.3.6"
#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 DevKit.ExecutionEngine.Redis@2026.3.6
#: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=DevKit.ExecutionEngine.Redis&version=2026.3.6
#tool nuget:?package=DevKit.ExecutionEngine.Redis&version=2026.3.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DevKit.ExecutionEngine.Redis
Servicio de caché distribuida utilizando Redis como backend, con soporte para generación automática de claves mediante expresiones lambda.
Características
- Generación automática de claves a partir de expresiones lambda
- Detección automática de la clase origen para evitar colisiones
- Soporte para tipos complejos, genéricos y colecciones
- Invalidación selectiva de caché
- Configuración flexible de TTL y entorno
- Manejo robusto de valores nulos y tipos primitivos
Instalación
- Configura la sección
RedisOptionsen tuappsettings.json:
{
"RedisOptions": {
"ConnectionRedis": "localhost:6379",
"Environment": "Development",
"DiasCache": 7
}
}
- Registra el servicio en el contenedor de dependencias:
services.AddRedisCache(ServiceLifetime.Scoped);
Uso
Inyección y Consumo
public class RolUseCase(IRolRepository repository, ICacheService cache) : IRolPort
{
public async Task<Rol> GetRolAsync(int rolID)
{
return await cache.GetOrSetAsync(() => repository.GetRolAsync(rolID));
}
public async Task<ICollection<RolPaginaConsulta>> GetRolPaginasAsync(int rolID)
{
return await cache.GetOrSetAsync(() => repository.GetRolPaginasAsync(rolID));
}
}
Invalidación de Caché
Invalida entradas específicas basadas en la misma expresión utilizada para el registro:
await _cacheService.InvalidateAsync(() => _repositorio.ObtenerProductosConsutlaAsync());
Generación de Claves
El sistema genera claves únicas automáticamente usando el formato:
{Environment}|{ClassName}:{MethodName}:{ReturnType}:{Parameters}
Ejemplos de Claves Generadas
// Para: RolUseCase.GetRolAsync(123)
"Development|RolUseCase:GetRolAsync:Rol:123"
// Para: RolUseCase.GetRolPaginasAsync(456)
"Development|RolUseCase:GetRolPaginasAsync:ICollection|RolPaginaConsulta|:456"
// Para: UserService.GetUsersByStatus("active", 1)
"Development|UserService:GetUsersByStatus:ICollection|User|:active:1"
Características de Generación de Claves
- Detección automática de clase: Identifica la clase que origina la llamada (ej:
RolUseCase) - Manejo de genéricos: Formatea tipos genéricos como
ICollection|RolPaginaConsulta| - Tipos complejos: Soporta DateTime, booleanos, diccionarios y colecciones
- Valores nulos: Maneja valores nulos de forma segura
- Sin colisiones: El diseño previene casi en su totalidad las colisiones de claves
Formateo de Valores
| Tipo | Formato | Ejemplo |
|---|---|---|
string |
Directo | "hello" |
int |
Directo | 123 |
DateTime |
ISO 8601 | "2024-03-06T10:30:00" |
bool |
Numérico | 1 o 0 |
null |
Texto | "NULL" |
List<T> |
Corchetes | "[1,2,3]" |
Dictionary<K,V> |
Pares clave-valor | "key1|value1,key2|value2" |
Configuración (RedisOptions)
ConnectionRedis: Cadena de conexión (ej. "localhost:6379").Environment: Prefijo para las claves (evita conflictos entre entornos).DiasCache: TTL por defecto para las nuevas entradas.
Mejoras Recientes
Mejoras en Nomenclatura
- Renombrado
FetchAndStoreValueAsync→GetAndCacheValueAsyncpara mayor claridad - Mejora en documentación XML en español
Mejoras en Generación de Claves
- Detección de clase origen: Las claves ahora comienzan con el nombre de la clase que realiza la llamada
- Orden optimizado:
ClassName:MethodName:ReturnType:Parameters - Identificación de contexto: Distingue entre clases concretas e interfaces de repositorio
Mejoras en Rendimiento
- Patrones async/await optimizados con
ConfigureAwait(false) - Configuración flexible de timeouts
- Manejo mejorado de cancelación
Arquitectura
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ RolUseCase │───▶│ CacheService │───▶│ Redis │
│ │ │ │ │ │
│ GetRolAsync() │ │ GetOrSetAsync() │ │ Key-Value Store│
│ │ │ │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌──────────────────┐
│ IRolRepository │ │ExpressionCondition│
│ │ │Extractor │
│ GetRolAsync() │ │ │
│ │ │BuildRedisKey() │
└─────────────────┘ └──────────────────┘
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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.
-
net10.0
- Microsoft.Extensions.Options (>= 10.0.3)
- StackExchange.Redis (>= 2.11.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.