ardalis / ardalis/CleanArchitecture

Add optional EF Core second-level query caching

Open
#1,074 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
18.5k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Description

Add optional EF Core second-level query caching to the Clean Architecture template.

The template currently uses EF Core with SQL Server and SQLite, but does not demonstrate second-level query caching.

An optional cache would provide an example of how frequently executed read queries can reduce database round trips while keeping the caching implementation inside the Infrastructure layer.

Suggested scope:

- Add an EF Core second-level cache provider.
- Keep caching disabled by default.
- Allow caching to be enabled through configuration.
- Use an in-memory cache provider for the initial implementation.
- Register the cache interceptor in the Infrastructure project.
- Demonstrate caching with one existing read query, for example the contributor list.
- Make the cache expiration configurable.
- Add tests for enabled and disabled caching.
- Document how to enable caching and how additional queries can opt in.

The Core and UseCases projects should not reference the concrete caching library.

Distributed caching, Redis, multi-instance synchronization, multi-tenancy, and bulk-write cache invalidation are outside the scope of this initial feature and can be addressed separately.

Would this feature be considered appropriate for the template? I would be interested in implementing it after the proposed scope has been agreed upon.

Contributor guide

Open the contributing guide

Research direction

Start by locating the Infrastructure project, the existing contributor-list read query, and the template's EF Core registrations for SQL Server and SQLite. Review how configuration and tests are organized, then verify an opt-in in-memory second-level cache, configurable expiration, enabled and disabled coverage, and documentation without Core or UseCases references.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.