You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* remove connection string (will add in note at bottom later) and reorder tutorial
* add a quick note about the connection string
* Apply suggestions from code review
* Update caching-components.md
Fix identation
* Update caching-components.md
---------
Co-authored-by: David Pine <[email protected]>
Copy file name to clipboardExpand all lines: docs/caching/caching-components.md
+36-40Lines changed: 36 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,39 @@ Visual Studio creates a new .NET Aspire solution that consists of the following
41
41
-**AspireRedis.AppHost** - An orchestrator project designed to connect and configure the different projects and services of your app.
42
42
-**AspireRedis.ServiceDefaults** - A .NET Aspire shared project to manage configurations that are reused across the projects in your solution related to [resilience](/dotnet/core/resilience/http-resilience), [service discovery](../service-discovery/overview.md), and [telemetry](../telemetry.md).
43
43
44
+
## Configure the App Host project
45
+
46
+
Update the _Program.cs_ file of the `AspireRedis.AppHost` project to match the following code:
The preceding code creates a local Redis container instance and configures the UI and API to use the instance automatically for both output and distributed caching. The code also configures communication between the frontend UI and the backend API using service discovery. With .NET Aspire's implicit service discovery, setting up and managing service connections is streamlined for developer productivity. In the context of this tutorial, the feature simplifies how you connect to Redis.
64
+
65
+
Traditionally, you'd manually specify the Redis connection string in each project's _appsettings.json_ file:
66
+
67
+
```json
68
+
{
69
+
"ConnectionStrings": {
70
+
"cache": "localhost:6379"
71
+
}
72
+
}
73
+
```
74
+
75
+
Configuring connection string with this method, while functional, requires duplicating the connection string across multiple projects, which can be cumbersome and error-prone.
76
+
44
77
## Configure the UI with output caching
45
78
46
79
1. Add the [.NET Aspire StackExchange Redis output caching](stackexchange-redis-output-caching-component.md) component packages to your `AspireStorage` app:
The preceding code creates a local Redis container instance and configures the UI and API to use the instance automatically for output and distributed caching. The code also configures communication between the frontend UI and the backend API using discovery.
0 commit comments