Skip to content

Add caching decorator with HybridCache and FusionCache support #291

Description

@iancooper

Summary

Provide a caching decorator so query results can be cached declaratively via an attribute like [CacheableQuery].

Context

From V5 discussion #273. Caching is one of the most common cross-cutting concerns for queries and is a natural fit for Darker's decorator pipeline.

Proposal

  • Create a [CacheableQuery] attribute with configurable expiry, cache key strategy, etc.
  • Create a CacheableQueryDecorator that checks the cache before invoking next, and populates the cache after
  • Support Microsoft's HybridCache (new in .NET 9) as the primary caching abstraction
  • Consider also supporting FusionCache as a popular alternative
  • Cache key generation should be pluggable (default: serialize the query object)
  • Support cache invalidation patterns (e.g. via QueryContext.Bag)
  • Package as Paramore.Darker.Caching or similar

Design Considerations

  • Queries are inherently cacheable (read-only, deterministic for the same input)
  • The decorator pattern makes this clean: cache check in Execute, populate on next return
  • Cache key must account for all query properties that affect the result

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions