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

Usage

PreviousRedisNextAPI

Last updated 1 year ago

Before continue with this section please follow steps.

After the configuration, you should install Eiffel.Caching.Abstractions NuGet package into your application. This package contains common interfaces such as , etc.

dotnet add package Eiffel.Caching.Abstractions

In your application services, controllers or other infrastructure service you can use ICacheService with dependency injection.

public class BookingService
{
    private readonly ICacheService _cacheService;
    public BookingService(ICacheService cacheService)
    {
        _cacheService = cacheService;
    }
    
    .. // Your implementation details
}

If you want to separate your data between different indexes in Redis you can use ICacheServiceFactory

public class BookingService
{
    const int BookingCacheIndex = 10;
    
    private readonly ICacheService _cacheService;
    public BookingService(ICacheServiceFactory cacheServiceFactory)
    {
        _cacheService = cacheServiceFactory.Resolve(BookingCacheIndex);
    }
    
    .. // Your implementation details 
}
configuration
ICacheService
ICacheServiceFactory