Skip to content

Add HybridCache documentation to caching guide#51461

Open
Copilot wants to merge 5 commits intomainfrom
copilot/update-caching-docs-hybridcache
Open

Add HybridCache documentation to caching guide#51461
Copilot wants to merge 5 commits intomainfrom
copilot/update-caching-docs-hybridcache

Conversation

Copy link
Contributor

Copilot AI commented Feb 4, 2026

Plan: Update Caching Documentation with HybridCache

  • Update the introduction section to mention HybridCache as a third caching approach
  • Add a new "HybridCache" section after "Worker Service caching" explaining:
    • What HybridCache is (combines in-memory and distributed caching)
    • Key features (stampede protection, configurable serialization, tag-based invalidation)
    • When to use it
  • Add HybridCache API documentation including:
    • Installation and registration
    • Basic GetOrCreateAsync usage
    • Configuration options
    • Tag-based invalidation
    • Serialization configuration
    • Distributed cache integration
  • Create code examples in ./snippets/caching/hybrid-cache/csharp/ folder
  • Build and test the examples
  • Address code review feedback (add region tags, improve comments)
  • Run security checks (CodeQL - no issues found)
  • Address PR feedback:
    • Target .NET 10 instead of .NET 9
    • Fix grammar (remove comma before "and provides")
    • Fix heading ("Configure" instead of "Configuring")
  • Final verification and documentation build

Summary

Successfully added comprehensive HybridCache documentation to the .NET caching guide. All feedback addressed.

Original prompt

This section details on the original issue you should resolve

<issue_title>Update Caching docs with HybridCache</issue_title>
<issue_description>### Type of issue

Need to update docs to contain HybridCache

Description

Prelim content found here:
https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid?view=aspnetcore-9.0

Page URL

https://learn.microsoft.com/en-us/dotnet/core/extensions/caching

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/extensions/caching.md

Document Version Independent Id

07beacc6-ddcf-2fd5-b896-00f999764b00

Platform Id

97e770aa-0b26-d69d-80e4-578056090645

Article author

@IEvangelist

Metadata

  • ID: ed120c7a-f4c0-c1d1-cb8c-168a3eba6dd9
  • PlatformId: 97e770aa-0b26-d69d-80e4-578056090645
  • Service: dotnet-fundamentals

Related Issues</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Internal previews

📄 File 🔗 Preview link
docs/core/extensions/caching.md Caching in .NET

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot AI changed the title [WIP] Update caching documentation with HybridCache details Add HybridCache documentation to caching guide Feb 4, 2026
Copilot AI requested a review from gewarren February 4, 2026 02:23
@gewarren
Copy link
Contributor

gewarren commented Feb 4, 2026

@copilot please respond to feedback.

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 4, 2026

@copilot please respond to feedback.

All feedback addressed in commit 207bf9c:

  • Updated project to target .NET 10
  • Fixed grammar in introduction
  • Updated heading to use imperative mood

Copilot AI requested a review from gewarren February 4, 2026 22:25
@gewarren gewarren marked this pull request as ready for review February 4, 2026 23:19
@gewarren gewarren requested a review from a team as a code owner February 4, 2026 23:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds comprehensive documentation for HybridCache to the .NET caching guide. HybridCache is a new caching library introduced in .NET 9 that combines in-memory and distributed caching with additional features like stampede protection and tag-based invalidation.

Changes:

  • Updated introduction to list HybridCache as a third caching approach alongside in-memory and distributed caching
  • Added complete HybridCache section with subsections covering key features, setup, usage, configuration, tag-based invalidation, and serialization
  • Created code examples demonstrating HybridCache functionality in a new snippets directory
  • Added HybridCache reference link to the "See also" section

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
docs/core/extensions/caching.md Added HybridCache section with comprehensive documentation, updated introduction to mention three caching approaches, and added reference link in "See also"
docs/core/extensions/snippets/caching/hybrid-cache/csharp/Program.cs Created code snippets demonstrating HybridCache registration, configuration, basic usage, tag-based caching, invalidation, serialization, and Redis integration
docs/core/extensions/snippets/caching/hybrid-cache/csharp/HybridCacheExample.csproj Created project file for code examples targeting .NET 10 with necessary package references

Comment on lines +5 to +13
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The project targets net10.0 but references version 9.0.0 packages. This creates a version mismatch. Either target net9.0 to match the package versions (9.0.0), or update the package versions to 10.0.0 if they're available for .NET 10. Since Microsoft.Extensions.Caching.Hybrid was introduced in .NET 9, and the example uses 9.0.0 packages, the target framework should be net9.0 for consistency.

Copilot uses AI. Check for mistakes.

Register the `HybridCache` service with DI by calling <xref:Microsoft.Extensions.DependencyInjection.HybridCacheServiceExtensions.AddHybridCache%2A>:

:::code source="snippets/caching/hybrid-cache/csharp/Program.cs" id="BasicRegistration" highlight="2-3":::
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The highlight attribute specifies "2-3" but the BasicRegistration snippet only contains 2 lines (lines 7-8 in Program.cs). The highlight should be "2" to highlight only the AddHybridCache() call, or if you want to highlight both lines, it should match the actual number of lines in the snippet.

Suggested change
:::code source="snippets/caching/hybrid-cache/csharp/Program.cs" id="BasicRegistration" highlight="2-3":::
:::code source="snippets/caching/hybrid-cache/csharp/Program.cs" id="BasicRegistration" highlight="2":::

Copilot uses AI. Check for mistakes.
Comment on lines +310 to +312
- <xref:Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions.Expiration?displayProperty=nameWithType>: How long the entry should be cached in the distributed cache.
- <xref:Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions.LocalCacheExpiration?displayProperty=nameWithType>: How long the entry should be cached in local memory.
- <xref:Microsoft.Extensions.Caching.Hybrid.HybridCacheEntryOptions.Flags?displayProperty=nameWithType>: Additional flags for controlling cache behavior.
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

These list items are sentence fragments that describe what can be configured, but they're written as incomplete sentences (e.g., "How long the entry should be cached..."). According to the Markdown writing style guidelines, list items should be complete sentences with proper punctuation. Rewrite these as complete sentences. For example: "The expiration determines how long the entry should be cached in the distributed cache." Alternatively, make them consistent descriptive phrases without periods if they're meant to be labels rather than sentences.

Copilot generated this review using guidance from repository custom instructions.
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.

Update Caching docs with HybridCache

2 participants