Eiffel
  • Overview
    • About
  • Features
    • Cross cutting concerns
      • API response consistency
      • Global exception handling
      • Idempotency
      • Audit logging
    • Caching
      • Configuration
        • In-Memory
        • Redis
      • Usage
      • API
        • CacheSource
        • InMemoryCacheOptions
        • RedisCacheOptions
        • ICacheService
        • ICacheServiceFactory
    • Localization
    • Job Processing
    • Multi-Tenancy
    • Metrics & monitoring
    • Transactional outbox
      • PostgreSQL
      • MongoDB (cluster only)
    • Messaging
      • Kafka
      • Rabbit MQ
      • Azure Service Bus
    • Awaitable socket client
    • Graceful shutdown
  • Fundamentals
    • Persistence
    • Modelling
  • Principles
    • Domain-Driven Design
      • Aggregates
      • Entities
      • Value Objects
      • Domain Events
      • Factories
      • Domain Services
      • Business Identifiers
      • Shared Kernel
    • Onion Architecture
      • Application Layer
      • Domain Layer
      • Infrastructure Layer
      • Anti-Corruption Layer
    • Modular Monolith Architecture
      • Modules
      • Shared Infrastructure
    • Microservice Architecture
      • API Gateway
      • View Model Composition
      • Contracts
  • Business Aligment
    • Domain Storytelling
    • User stories
  • Implementation
    • Modular Monolith
    • Microservices
  • Testing
    • Unit Testing
    • Integration Testing
    • Contract Testing
  • Cloud Infrastructure
    • CI/CD Pipelines
    • Docker
    • Kubernates
    • Infrastructure as Code
Powered by GitBook
On this page
  1. Features
  2. Caching

Configuration

PreviousCachingNextIn-Memory

Last updated 1 year ago

Caching module requires serveral NuGet package installations. First you need to install Eiffel.Caching.Extensions.DependencyInjection package.

dotnet add package Eiffel.Caching.Extensions.DependencyInjection

After the installation, AddCaching extension method will be accessible from WebApplicationBuilder class instance.

The Caching module provides distributed and in-memory caching options. The enum provides a list of supported cache sources

You can use the AddCaching method without parameters, but in that case, you must define the Caching section with the related source configuration in the appsettings.json file.

// Program.cs (.NET5 and above)
public static async Task Main(string[] args)
{
    var builder = WebApplication.CreateBuilder(args);
    
    // Add caching
    builder.AddCaching();
     
    var app = builder.Build();
    app.Run();
}

Example Redis configuration section. For configuration details please .

{
    "Caching": {
        "Source": "Redis",
        "Redis": {
            ... // Put your redis configuration values here
        }
    }
}
{
    "Caching": {
        "Source": "InMemory",
        "InMemory": {
            ... // Put your in-memory configuration values here
        }
    }
}

Example In-Memory configuration section. For configuration details please .

CacheSource
read
read