Skip to content

Add an overview of Stack Exchange Redis caching #1064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/caching/caching-components-deployment.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Deploy a .NET Aspire app that connects to Redis Cache to Azure
description: Learn how to deploy a .NET Aspire app that connects to Redis Cache to Azure
ms.date: 05/14/2024
ms.date: 06/11/2024
ms.topic: how-to
---

Expand Down
6 changes: 3 additions & 3 deletions docs/caching/caching-components.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Implement caching with .NET Aspire components
description: Learn how to connect to Redis and cache data using .NET Aspire components.
ms.date: 06/05/2024
ms.date: 06/11/2024
ms.topic: tutorial
---

Expand Down Expand Up @@ -96,7 +96,7 @@ Configuring connection string with this method, while functional, requires dupli

## Configure the UI with output caching

1. Add the [.NET Aspire StackExchange Redis output caching](stackexchange-redis-output-caching-component.md) component packages to your `AspireRedis.Web` app:
1. Add the [.NET Aspire Stack Exchange Redis output caching](stackexchange-redis-output-caching-component.md) component packages to your `AspireRedis.Web` app:

```dotnetcli
dotnet add package Aspire.StackExchange.Redis.OutputCaching
Expand Down Expand Up @@ -130,7 +130,7 @@ Configuring connection string with this method, while functional, requires dupli

## Configure the API with distributed caching

1. Add the [.NET Aspire StackExchange Redis distributed caching](stackexchange-redis-output-caching-component.md) component packages to your `AspireRedis.ApiService` app:
1. Add the [.NET Aspire Stack Exchange Redis distributed caching](stackexchange-redis-output-caching-component.md) component packages to your `AspireRedis.ApiService` app:

```dotnetcli
dotnet add package Aspire.StackExchange.Redis.DistributedCaching
Expand Down
2 changes: 1 addition & 1 deletion docs/caching/includes/redis-app-host.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ dotnet add package Aspire.Hosting.Redis

---

In your app host project, register the .NET Aspire StackExchange Redis as a resource using the <xref:Aspire.Hosting.RedisBuilderExtensions.AddRedis%2A> method and consume the service using the following methods:
In your app host project, register the .NET Aspire Stack Exchange Redis as a resource using the <xref:Aspire.Hosting.RedisBuilderExtensions.AddRedis%2A> method and consume the service using the following methods:
40 changes: 40 additions & 0 deletions docs/caching/stackexchange-redis-caching-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: Stack Exchange Redis caching overview
description: Learn about Stack Exchange Redis caching and how to use it in your applications.
ms.date: 06/11/2024
---

# Stack Exchange Redis caching overview

With .NET Aspire, there are several ways to use caching in your applications. One popular option is to use [Stack Exchange Redis](https://stackexchange.github.io/StackExchange.Redis), which is a high-performance data store that can be used to store frequently accessed data. This article provides an overview of Stack Exchange Redis caching and links to resources that help you use it in your applications.

To use multiple Redis caching components in your application, see the [Tutorial: Implement caching with .NET Aspire components](caching-components.md). If you're interested in using the Redis Cache for Azure, see the [Tutorial: Deploy a .NET Aspire app with a Redis Cache to Azure](caching-components-deployment.md).

## Caching

Caching is a technique used to store frequently accessed data in memory. This helps to reduce the time it takes to retrieve the data from the original source, such as a database or a web service. Caching can significantly improve the performance of an application by reducing the number of requests made to the original source. To access the Redis `IConnectionMultiplexer` object, you use the `Aspire.StackExchange.Redis` NuGet package:

> [!div class="nextstepaction"]
> [.NET Aspire Stack Exchange Redis component](stackexchange-redis-component.md)

## Distributed caching

Distributed caching is a type of caching that stores data across multiple servers. This allows the data to be shared between multiple instances of an application, which can help to improve scalability and performance. Distributed caching can be used to store a wide variety of data, such as session state, user profiles, and frequently accessed data. To use Redis distributed caching in your application (the `IDistributedCache` interface), use the `Aspire.StackExchange.Redis.DistributedCaching` NuGet package:

> [!div class="nextstepaction"]
> [.NET Aspire Stack Exchange Redis distributed caching component](stackexchange-redis-distributed-caching-component.md)

## Output caching

Output caching is a type of caching that stores the output of a web page or API response. This allows the response to be served directly from the cache, rather than generating it from scratch each time. Output caching can help to improve the performance of a web application by reducing the time it takes to generate a response. To use declarative Redis output caching with either the `OutputCache` attribute or the `CacheOutput` method in your application, use the `Aspire.StackExchange.Redis.OutputCaching` NuGet package:

> [!div class="nextstepaction"]
> [.NET Aspire Stack Exchange Redis output caching component](stackexchange-redis-output-caching-component.md)

## See also

- [Caching in .NET](/dotnet/core/extensions/caching)
- [Overview of Caching in ASP.NET Core](/aspnet/core/performance/caching/overview)
- [Distributed caching in .NET](/dotnet/core/extensions/caching#distributed-caching)
- [Distributed caching in ASP.NET Core](/aspnet/core/performance/caching/distributed)
- [Output caching middleware in ASP.NET Core](/aspnet/core/performance/caching/output)
28 changes: 14 additions & 14 deletions docs/caching/stackexchange-redis-component.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: .NET Aspire StackExchange Redis component
description: This article describes the .NET Aspire StackExchange Redis component features and capabilities
title: .NET Aspire Stack Exchange Redis component
description: This article describes the .NET Aspire Stack Exchange Redis component features and capabilities
ms.topic: how-to
ms.date: 06/05/2024
ms.date: 06/11/2024
---

# .NET Aspire StackExchange Redis component
# .NET Aspire Stack Exchange Redis component

In this article, you learn how to use the .NET Aspire StackExchange Redis component. The `Aspire.StackExchange.Redis` library is used to register an [IConnectionMultiplexer](https://stackexchange.github.io/StackExchange.Redis/Basics) in the DI container for connecting to a [Redis](https://redis.io/) server. It enables corresponding health checks, logging and telemetry.
In this article, you learn how to use the .NET Aspire Stack Exchange Redis component. The `Aspire.StackExchange.Redis` library is used to register an [IConnectionMultiplexer](https://stackexchange.github.io/StackExchange.Redis/Basics) in the DI container for connecting to a [Redis](https://redis.io/) server. It enables corresponding health checks, logging and telemetry.

## Get started

To get started with the .NET Aspire StackExchange Redis component, install the [Aspire.StackExchange.Redis](https://www.nuget.org/packages/Aspire.StackExchange.Redis) NuGet package.
To get started with the .NET Aspire Stack Exchange Redis component, install the [Aspire.StackExchange.Redis](https://www.nuget.org/packages/Aspire.StackExchange.Redis) NuGet package.

### [.NET CLI](#tab/dotnet-cli)

Expand Down Expand Up @@ -68,7 +68,7 @@ builder.AddRedis("cache");

## Configuration

The .NET Aspire StackExchange Redis component provides multiple options to configure the Redis connection based on the requirements and conventions of your project.
The .NET Aspire Stack Exchange Redis component provides multiple options to configure the Redis connection based on the requirements and conventions of your project.

### Use a connection string

Expand All @@ -88,11 +88,11 @@ And then the connection string will be retrieved from the `ConnectionStrings` co
}
```

For more information on how to format this connection string, see the [StackExchange Redis configuration docs](https://stackexchange.github.io/StackExchange.Redis/Configuration.html#basic-configuration-strings).
For more information on how to format this connection string, see the [Stack Exchange Redis configuration docs](https://stackexchange.github.io/StackExchange.Redis/Configuration.html#basic-configuration-strings).

### Use configuration providers

The .NET Aspire StackExchange Redis component supports <xref:Microsoft.Extensions.Configuration?displayProperty=fullName>. It loads the <xref:Aspire.StackExchange.Redis.StackExchangeRedisSettings> from configuration by using the `Aspire:StackExchange:Redis` key. Example _:::no-loc text="appsettings.json":::_ that configures some of the options:
The .NET Aspire Stack Exchange Redis component supports <xref:Microsoft.Extensions.Configuration?displayProperty=fullName>. It loads the <xref:Aspire.StackExchange.Redis.StackExchangeRedisSettings> from configuration by using the `Aspire:StackExchange:Redis` key. Example _:::no-loc text="appsettings.json":::_ that configures some of the options:

```json
{
Expand Down Expand Up @@ -123,7 +123,7 @@ builder.AddRedis(

[!INCLUDE [component-health-checks](../includes/component-health-checks.md)]

The .NET Aspire StackExchange Redis component handles the following:
The .NET Aspire Stack Exchange Redis component handles the following:

- Adds the `StackExchange.Redis` health check, tries to open the connection and throws when it fails.
- Integrates with the `/health` HTTP endpoint, which specifies all registered health checks must pass for app to be considered ready to accept traffic
Expand All @@ -132,22 +132,22 @@ The .NET Aspire StackExchange Redis component handles the following:

### Logging

The .NET Aspire StackExchange Redis component uses the following log categories:
The .NET Aspire Stack Exchange Redis component uses the following log categories:

- `Aspire.StackExchange.Redis`

### Tracing

The .NET Aspire StackExchange Redis component will emit the following tracing activities using OpenTelemetry:
The .NET Aspire Stack Exchange Redis component will emit the following tracing activities using OpenTelemetry:

- "OpenTelemetry.Instrumentation.StackExchangeRedis"

### Metrics

The .NET Aspire StackExchange Redis component currently doesn't support metrics by default due to limitations with the `StackExchange.Redis` library.
The .NET Aspire Stack Exchange Redis component currently doesn't support metrics by default due to limitations with the `StackExchange.Redis` library.

## See also

- [StackExchange Redis docs](https://stackexchange.github.io/StackExchange.Redis/)
- [Stack Exchange Redis docs](https://stackexchange.github.io/StackExchange.Redis/)
- [.NET Aspire components](../fundamentals/components-overview.md)
- [.NET Aspire GitHub repo](https://github.com/dotnet/aspire)
28 changes: 14 additions & 14 deletions docs/caching/stackexchange-redis-distributed-caching-component.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: .NET Aspire StackExchange Redis distributed caching component
description: This article describes the .NET Aspire StackExchange Redis distributed caching component features and capabilities
title: .NET Aspire Stack Exchange Redis distributed caching component
description: This article describes the .NET Aspire Stack Exchange Redis distributed caching component features and capabilities
ms.topic: how-to
ms.date: 06/05/2024
ms.date: 06/11/2024
---

# .NET Aspire StackExchange Redis distributed caching component
# .NET Aspire Stack Exchange Redis distributed caching component

In this article, you learn how to use the .NET Aspire StackExchange Redis distributed caching component. The `Aspire.StackExchange.Redis.DistributedCaching` library is used to register an [IDistributedCache](https://stackexchange.github.io/StackExchange.Redis/Basics) provider for connecting to [Redis](https://redis.io/) server. It enables corresponding health checks, logging and telemetry.
In this article, you learn how to use the .NET Aspire Stack Exchange Redis distributed caching component. The `Aspire.StackExchange.Redis.DistributedCaching` library is used to register an [IDistributedCache](https://stackexchange.github.io/StackExchange.Redis/Basics) provider for connecting to [Redis](https://redis.io/) server. It enables corresponding health checks, logging and telemetry.

## Get started

To get started with the .NET Aspire StackExchange Redis distributed caching component, install the [Aspire.StackExchange.Redis.DistributedCaching](https://www.nuget.org/packages/Aspire.StackExchange.Redis.DistributedCaching) NuGet package.
To get started with the .NET Aspire Stack Exchange Redis distributed caching component, install the [Aspire.StackExchange.Redis.DistributedCaching](https://www.nuget.org/packages/Aspire.StackExchange.Redis.DistributedCaching) NuGet package.

### [.NET CLI](#tab/dotnet-cli)

Expand Down Expand Up @@ -68,7 +68,7 @@ builder.AddRedisDistributedCache("cache");

## Configuration

The .NET Aspire StackExchange Redis distributed caching component provides multiple options to configure the Redis connection based on the requirements and conventions of your project.
The .NET Aspire Stack Exchange Redis distributed caching component provides multiple options to configure the Redis connection based on the requirements and conventions of your project.

### Use a connection string

Expand All @@ -88,11 +88,11 @@ And then the connection string will be retrieved from the `ConnectionStrings` co
}
```

For more information on how to format this connection string, see the [StackExchange Redis configuration docs](https://stackexchange.github.io/StackExchange.Redis/Configuration.html#basic-configuration-strings).
For more information on how to format this connection string, see the [Stack Exchange Redis configuration docs](https://stackexchange.github.io/StackExchange.Redis/Configuration.html#basic-configuration-strings).

### Use configuration providers

The .NET Aspire StackExchange Redis distributed caching component supports <xref:Microsoft.Extensions.Configuration?displayProperty=fullName>. It loads the <xref:Aspire.StackExchange.Redis.StackExchangeRedisSettings> from configuration by using the `Aspire:StackExchange:Redis` key. Example _:::no-loc text="appsettings.json":::_ that configures some of the options:
The .NET Aspire Stack Exchange Redis distributed caching component supports <xref:Microsoft.Extensions.Configuration?displayProperty=fullName>. It loads the <xref:Aspire.StackExchange.Redis.StackExchangeRedisSettings> from configuration by using the `Aspire:StackExchange:Redis` key. Example _:::no-loc text="appsettings.json":::_ that configures some of the options:

```json
{
Expand Down Expand Up @@ -131,7 +131,7 @@ builder.AddRedisDistributedCache(

[!INCLUDE [component-health-checks](../includes/component-health-checks.md)]

The .NET Aspire StackExchange Redis distributed caching component handles the following:
The .NET Aspire Stack Exchange Redis distributed caching component handles the following:

- Adds the `StackExchange.Redis` health check, tries to open the connection and throws when it fails.
- Integrates with the `/health` HTTP endpoint, which specifies all registered health checks must pass for app to be considered ready to accept traffic
Expand All @@ -140,23 +140,23 @@ The .NET Aspire StackExchange Redis distributed caching component handles the fo

### Logging

The .NET Aspire StackExchange Redis Distributed Caching component uses the following Log categories:
The .NET Aspire Stack Exchange Redis Distributed Caching component uses the following Log categories:

- `Aspire.StackExchange.Redis`
- `Microsoft.Extensions.Caching.StackExchangeRedis`

### Tracing

The .NET Aspire StackExchange Redis Distributed Caching component will emit the following Tracing activities using OpenTelemetry:
The .NET Aspire Stack Exchange Redis Distributed Caching component will emit the following Tracing activities using OpenTelemetry:

- "OpenTelemetry.Instrumentation.StackExchangeRedis"

### Metrics

The .NET Aspire StackExchange Redis Distributed Caching component currently doesn't support metrics by default due to limitations with the `StackExchange.Redis` library.
The .NET Aspire Stack Exchange Redis Distributed Caching component currently doesn't support metrics by default due to limitations with the `StackExchange.Redis` library.

## See also

- [StackExchange Redis docs](https://stackexchange.github.io/StackExchange.Redis/)
- [Stack Exchange Redis docs](https://stackexchange.github.io/StackExchange.Redis/)
- [.NET Aspire components](../fundamentals/components-overview.md)
- [.NET Aspire GitHub repo](https://github.com/dotnet/aspire)
Loading
Loading