feat: add Cache Stampede Protection pattern#456
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR adds the Cache Stampede Protection pattern to PatternKit, including a core keyed single-flight policy, source-generator support, example/DI integration, tests, benchmarks, and documentation/catalog updates.
Changes:
- Adds
CacheStampedeProtectionPolicy<TResult>and generated factory support via[GenerateCacheStampedeProtection]. - Adds product catalog demo, DI registration, benchmark routes, and TinyBDD coverage.
- Updates catalog counts, benchmark matrices, README, docs indexes, TOCs, and pattern/generator/example docs.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/PatternKit.Core/Cloud/CacheStampedeProtection/CacheStampedeProtectionPolicy.cs |
Adds the keyed single-flight runtime policy and result model. |
src/PatternKit.Generators/CacheStampedeProtection/CacheStampedeProtectionGenerator.cs |
Adds the source generator for policy factory creation. |
src/PatternKit.Generators.Abstractions/CacheStampedeProtection/CacheStampedeProtectionAttributes.cs |
Adds the generator attribute abstraction. |
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md |
Registers new PKCSP diagnostics. |
src/PatternKit.Examples/CacheStampedeProtectionDemo/ProductCatalogStampedeProtectionDemo.cs |
Adds the product catalog cache stampede protection example and DI extension. |
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs |
Adds aggregate DI registration and example record. |
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs |
Adds the new catalog pattern entry. |
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs |
Adds the new example catalog descriptor. |
benchmarks/PatternKit.Benchmarks/Cloud/CacheStampedeProtectionBenchmarks.cs |
Adds construction and execution benchmark routes. |
test/PatternKit.Tests/Cloud/CacheStampedeProtection/CacheStampedeProtectionPolicyTests.cs |
Adds runtime behavior tests for sharing, key isolation, failures, cancellation, and validation. |
test/PatternKit.Generators.Tests/CacheStampedeProtectionGeneratorTests.cs |
Adds generator output and diagnostic tests. |
test/PatternKit.Generators.Tests/AbstractionsTests.cs |
Adds attribute constructor and usage tests. |
test/PatternKit.Examples.Tests/CacheStampedeProtectionDemo/ProductCatalogStampedeProtectionDemoTests.cs |
Adds example and DI integration tests. |
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs |
Updates pattern count expectations. |
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitBenchmarkCoverageTests.cs |
Updates benchmark route total expectation. |
README.md |
Updates pattern totals and benchmark table entries. |
docs/index.md |
Updates documentation landing-page pattern totals. |
docs/patterns/toc.yml |
Adds the pattern docs TOC entry. |
docs/patterns/cloud/cache-stampede-protection.md |
Adds pattern documentation. |
docs/generators/toc.yml |
Adds generator docs TOC entry. |
docs/generators/index.md |
Adds generator index entry. |
docs/generators/cache-stampede-protection.md |
Adds generator documentation. |
docs/examples/toc.yml |
Adds example docs TOC entry. |
docs/examples/product-catalog-cache-stampede-protection.md |
Adds example documentation. |
docs/guides/pattern-coverage.md |
Updates pattern coverage matrix. |
docs/guides/benchmarks.md |
Adds benchmark placeholder rows. |
docs/guides/benchmark-results.md |
Updates benchmark results, route totals, and generator coverage entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return; | ||
| } | ||
|
|
||
| context.AddSource($"{type.Name}.CacheStampedeProtection.g.cs", SourceText.From( |
| 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(); |
Test Results 12 files 12 suites 10m 41s ⏱️ Results for commit 54dbaf2. ♻️ This comment has been updated with latest results. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #456 +/- ##
==========================================
+ Coverage 96.63% 96.80% +0.17%
==========================================
Files 559 563 +4
Lines 45502 45742 +240
Branches 3000 6584 +3584
==========================================
+ Hits 43969 44280 +311
+ Misses 1533 1462 -71
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
5bea174 to
54dbaf2
Compare
Code Coverage |
Summary
Closes #449
Verification
CacheStampedeProtectionGeneratorTests|FullyQualifiedNameAbstractionsTests" -p:TestTfmsInParallel=false --logger "console;verbosity=minimal"CacheStampedeProtectionDemo|FullyQualifiedNameProductionReadiness|FullyQualifiedName~DependencyInjection" -p:TestTfmsInParallel=false --logger "console;verbosity=minimal"