Skip to content

feat: add query caching for EF Core and Dapper - #3

Open
AmirTahan80 wants to merge 1 commit into
PepperX-Dev:mainfrom
AmirTahan80:feat/query-caching
Open

AmirTahan80 wants to merge 1 commit into
PepperX-Dev:mainfrom
AmirTahan80:feat/query-caching

Conversation

@AmirTahan80

Copy link
Copy Markdown
Contributor

Summary

Adds query caching capabilities to optimize query execution in both Entity Framework Core and Dapper.

Key Additions & Features

  • Core Abstractions (PepperX.QueryForge):
    • IQueryCache and QueryCacheOptions: configurable caching interface supporting absolute expiration, sliding expiration, tags, and key prefixing.
    • MemoryQueryCache: high-performance in-memory cache implementation with automatic cleanup and tag invalidation.
    • QueryCacheKeyGenerator: deterministic SHA-256 cache key generation based on query criteria, selected columns, paging, sorting, and grouping.
    • Fluent extension methods (WithCache, WithCacheOptions, WithoutCache).
    • QueryForgeCache.Default: global cache provider accessor.
  • Dapper Provider (PepperX.QueryForge.Dapper):
    • Integrated caching into QueryExecutor via DapperQueryForgeOptions.
    • Added fluent caching configuration on DapperQueryFluent.
  • EF Core Provider (PepperX.QueryForge.EFCore):
    • Transparent second-level caching interceptor in ToQueryResultAsync and helper extensions ToQueryResultCachedAsync.
  • Sample WebApi & Requests:
    • Added cached query endpoints for Dapper and EF Core (/api/users/cached, /api/efcore/users/cached).
    • Added cache management endpoints for tag-based invalidation and full cache clearing (/api/cache/invalidate, /api/cache/clear).
    • Updated Requests.http with sample requests covering cached queries and cache management.
  • Unit & Provider Tests:
    • Full test suite covering cache operations, key generation, sliding TTL, tag invalidation, and execution across providers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant