Skip to content

feat: add Read-Through and Write-Through Cache patterns#457

Merged
JerrettDavis merged 1 commit into
mainfrom
feat/read-write-through-cache-450
May 30, 2026
Merged

feat: add Read-Through and Write-Through Cache patterns#457
JerrettDavis merged 1 commit into
mainfrom
feat/read-write-through-cache-450

Conversation

@JerrettDavis

Copy link
Copy Markdown
Owner

Summary

  • adds a shared read/write-through cache policy for cache-owned repository reads and persistence-first cache updates
  • adds source-generated factory support, product catalog IServiceCollection demo, docs, catalog entries, and benchmark rows
  • adds TinyBDD coverage for runtime behavior, generator diagnostics/output, abstractions, examples, DI, and production-readiness audits

Closes #450

Verification

  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj --configuration Release --no-restore --filter "FullyQualifiedName~ReadWriteThroughCachePolicyTests" -p:TestTfmsInParallel=false --logger "console;verbosity=minimal"
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj --configuration Release --no-restore --filter "FullyQualifiedNameReadWriteThroughCachePolicyGeneratorTests|FullyQualifiedNameAbstractions" -p:TestTfmsInParallel=false --logger "console;verbosity=minimal"
  • dotnet test test\PatternKit.Examples.Tests\PatternKit.Examples.Tests.csproj --configuration Release --no-restore --filter "FullyQualifiedNameReadWriteThroughCacheDemo|FullyQualifiedNameProductionReadiness|FullyQualifiedName~DependencyInjection" -p:TestTfmsInParallel=false --logger "console;verbosity=minimal"
  • dotnet format PatternKit.slnx --verify-no-changes --verbosity minimal
  • dotnet build PatternKit.slnx --configuration Release --no-restore
  • dotnet test PatternKit.slnx --configuration Release --no-build -p:TestTfmsInParallel=false --logger "console;verbosity=minimal"

Copilot AI review requested due to automatic review settings May 30, 2026 16:58
@github-actions

github-actions Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Read-Through and Write-Through Cache support across the runtime library, source generator surface, examples, docs, benchmarks, and production-readiness catalogs.

Changes:

  • Introduces ReadWriteThroughCachePolicy<TResult> for cache-owned reads, write-through updates, invalidation, TTL, and shared cache-store support.
  • Adds [GenerateReadWriteThroughCachePolicy], generator diagnostics/output tests, and generated factory documentation.
  • Adds product catalog examples, DI registration, catalog entries, benchmark coverage rows, and TinyBDD coverage.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/PatternKit.Core/Cloud/ReadWriteThroughCache/ReadWriteThroughCachePolicy.cs Adds runtime read/write-through cache policy and result model.
src/PatternKit.Generators.Abstractions/ReadWriteThroughCache/ReadWriteThroughCacheAttributes.cs Adds generator attribute abstraction.
src/PatternKit.Generators/ReadWriteThroughCache/ReadWriteThroughCachePolicyGenerator.cs Adds source generator for cache policy factories.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Registers new generator diagnostics.
src/PatternKit.Examples/ReadWriteThroughCacheDemo/ProductCatalogReadWriteThroughCacheDemo.cs Adds product catalog runtime/generated/DI example.
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Wires the new example into aggregate DI registration.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Adds Read-Through and Write-Through Cache catalog entries.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds example catalog descriptor.
benchmarks/PatternKit.Benchmarks/Cloud/ReadWriteThroughCacheBenchmarks.cs Adds construction/execution benchmarks.
test/PatternKit.Tests/Cloud/ReadWriteThroughCache/ReadWriteThroughCachePolicyTests.cs Adds runtime policy behavior tests.
test/PatternKit.Generators.Tests/ReadWriteThroughCachePolicyGeneratorTests.cs Adds generator output/diagnostic tests.
test/PatternKit.Generators.Tests/AbstractionsTests.cs Adds abstraction constructor/usage tests.
test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs Adds abstraction coverage entries.
test/PatternKit.Examples.Tests/ReadWriteThroughCacheDemo/ProductCatalogReadWriteThroughCacheDemoTests.cs Adds example and DI behavior tests.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Updates pattern counts and expected catalog names.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitBenchmarkCoverageTests.cs Updates benchmark route totals and humanization.
README.md Updates pattern counts and benchmark matrix rows.
docs/index.md Updates public pattern counts/table.
docs/patterns/toc.yml Adds pattern documentation TOC entry.
docs/patterns/cloud/read-write-through-cache.md Adds pattern documentation.
docs/generators/index.md Adds generator index entry.
docs/generators/toc.yml Adds generator TOC entry.
docs/generators/read-write-through-cache.md Adds generator documentation.
docs/examples/toc.yml Adds example TOC entry.
docs/examples/product-catalog-read-write-through-cache.md Adds example documentation.
docs/guides/pattern-coverage.md Updates pattern coverage guide.
docs/guides/benchmarks.md Adds benchmark guide rows.
docs/guides/benchmark-results.md Updates benchmark result rows and coverage totals.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +90 to +99
sb.Append(GetAccessibility(type.DeclaredAccessibility)).Append(' ');
if (type.IsStatic)
sb.Append("static ");
else if (type.IsAbstract && type.TypeKind == TypeKind.Class)
sb.Append("abstract ");
else if (type.IsSealed && type.TypeKind == TypeKind.Class)
sb.Append("sealed ");
sb.Append("partial ").Append(type.TypeKind == TypeKind.Struct ? "struct" : "class").Append(' ').Append(type.Name).AppendLine();
sb.AppendLine("{");
sb.Append(" public static global::PatternKit.Cloud.ReadWriteThroughCache.ReadWriteThroughCachePolicy<").Append(resultTypeName).Append("> ").Append(factoryMethodName).AppendLine("()");
@github-actions

github-actions Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Test Results

    12 files      12 suites   11m 34s ⏱️
 3 888 tests  3 888 ✅ 0 💤 0 ❌
12 095 runs  12 095 ✅ 0 💤 0 ❌

Results for commit 4391b20.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

🔍 PR Validation Results

Version: ``

✅ Validation Steps

  • Build solution
  • Run tests
  • Build documentation
  • Dry-run NuGet packaging

📊 Artifacts

Dry-run artifacts have been uploaded and will be available for 7 days.


This comment was automatically generated by the PR validation workflow.

@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.57806% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.82%. Comparing base (2b11edf) to head (4391b20).

Files with missing lines Patch % Lines
...roughCache/ReadWriteThroughCachePolicyGenerator.cs 98.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #457      +/-   ##
==========================================
+ Coverage   96.64%   96.82%   +0.17%     
==========================================
  Files         563      567       +4     
  Lines       45742    45979     +237     
  Branches     3011     6611    +3600     
==========================================
+ Hits        44208    44519     +311     
+ Misses       1534     1460      -74     
Flag Coverage Δ
unittests 96.82% <99.57%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JerrettDavis
JerrettDavis force-pushed the feat/read-write-through-cache-450 branch from 6379ba2 to 4391b20 Compare May 30, 2026 17:15
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/30/2026 - 17:23:48
  Coverage date: 05/30/2026 - 17:21:08 - 05/30/2026 - 17:23:37
  Parser: MultiReport (12x Cobertura)
  Assemblies: 5
  Classes: 1665
  Files: 567
  Line coverage: 96.6%
  Covered lines: 44442
  Uncovered lines: 1537
  Coverable lines: 45979
  Total lines: 98617
  Branch coverage: 82.3% (13866 of 16845)
  Covered branches: 13866
  Total branches: 16845
  Method coverage: 96.7% (8658 of 8950)
  Full method coverage: 90.3% (8090 of 8950)
  Covered methods: 8658
  Fully covered methods: 8090
  Total methods: 8950

PatternKit.Core                                                                                                     95.6%
  PatternKit.Application.ActivityTracking.ActivityGateState                                                          100%
  PatternKit.Application.ActivityTracking.ActivityLease                                                              100%
  PatternKit.Application.ActivityTracking.ActivityRecord                                                             100%
  PatternKit.Application.ActivityTracking.ActivityTracker                                                            100%
  PatternKit.Application.Aggregates.AggregateCommandHandler<T1, T2, T3>                                              100%
  PatternKit.Application.Aggregates.AggregateCommandResult<T>                                                        100%
  PatternKit.Application.Aggregates.AggregateRoot<T1, T2>                                                            100%
  PatternKit.Application.AntiCorruption.AntiCorruptionLayer<T1, T2>                                                 90.4%
  PatternKit.Application.AntiCorruption.AntiCorruptionResult<T>                                                      100%
  PatternKit.Application.AuditLog.AuditLogAppendResult<T>                                                           85.7%
  PatternKit.Application.AuditLog.InMemoryAuditLog<T1, T2>                                                          95.4%
  PatternKit.Application.BoundedContexts.BoundedContextAdapter                                                       100%
  PatternKit.Application.BoundedContexts.BoundedContextCapability                                                   83.3%
  PatternKit.Application.BoundedContexts.BoundedContextDescriptor                                                   95.4%
  PatternKit.Application.ContextMaps.ContextMapDescriptor                                                           96.8%
  PatternKit.Application.ContextMaps.ContextMapRelationship                                                          100%
  PatternKit.Application.DataMapping.DataMapper<T1, T2>                                                             94.6%
  PatternKit.Application.DataMapping.DataMapperError                                                                  90%
  PatternKit.Application.DataMapping.DataMapperResult<T>                                                            84.6%
  PatternKit.Application.DomainEvents.DomainEventDispatcher<T>                                                      95.4%
  PatternKit.Application.DomainEvents.DomainEventDispatchResult                                                      100%
  PatternKit.Application.DomainServices.DomainServiceOperation<T1, T2>                                               100%
  PatternKit.Application.DomainServices.DomainServiceRegistry<T1, T2>                                                100%
  PatternKit.Application.EventSourcing.EventStoreAppendResult                                                        100%
  PatternKit.Application.EventSourcing.InMemoryEventStore<T1, T2>                                                   97.9%
  PatternKit.Application.EventSourcing.StoredEvent<T1, T2>                                                            80%
  PatternKit.Application.FeatureToggles.FeatureToggleDecision                                                       87.5%
  PatternKit.Application.FeatureToggles.FeatureToggleRule<T>                                                         100%
  PatternKit.Application.FeatureToggles.FeatureToggleSet<T>                                                         96.9%
  PatternKit.Application.IdentityMap.IdentityMap<T1, T2>                                                             100%
  PatternKit.Application.IdentityMap.IdentityMapResult<T>                                                           92.8%
  PatternKit.Application.ManualTaskGates.ManualTaskGate<T>                                                          98.5%
  PatternKit.Application.ManualTaskGates.ManualTaskGateState<T>                                                      100%
  PatternKit.Application.ManualTaskGates.ManualTaskRecord<T>                                                        96.9%
  PatternKit.Application.MaterializedViews.MaterializedView<T1, T2>                                                 98.4%
  PatternKit.Application.Repository.InMemoryRepository<T1, T2>                                                      92.8%
  PatternKit.Application.Repository.RepositoryResult<T>                                                             93.3%
  PatternKit.Application.ServiceLayer.ServiceLayerOperation<T1, T2>                                                 96.7%

@JerrettDavis
JerrettDavis merged commit 23428a4 into main May 30, 2026
12 checks passed
@JerrettDavis
JerrettDavis deleted the feat/read-write-through-cache-450 branch May 30, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Read-Through and Write-Through Cache patterns

2 participants