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
Copy file name to clipboardExpand all lines: articles/azure-cache-for-redis/cache-aspnet-output-cache-provider.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,8 +15,7 @@ The Redis Output Cache Provider is an out-of-process storage mechanism for outpu
15
15
16
16
For ASP.NET Core applications, see [Output Caching in ASP.NET core using Redis in .NET 8](/aspnet/core/performance/caching/output?view=aspnetcore-8.0#redis-cache&preserve-view=true).
17
17
18
-
<!-- This section points to create azure cache for redis instead of amr. Not sure if this article was updated or not? -->
19
-
To use the Redis Output Cache Provider, first configure your cache, and then configure your ASP.NET application using the Redis Output Cache Provider NuGet package. This article provides guidance on configuring your application to use the Redis Output Cache Provider. For more information about creating and configuring an Azure Managed Redis (preview) instance, see [Create a cache](cache-dotnet-how-to-use-azure-redis-cache.md#create-a-cache).
18
+
To use the Redis Output Cache Provider, first configure your cache, and then configure your ASP.NET application using the Redis Output Cache Provider NuGet package. This article provides guidance on configuring your application to use the Redis Output Cache Provider.
Copy file name to clipboardExpand all lines: articles/azure-cache-for-redis/cache-development-faq.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ sections:
51
51
### Timeout values
52
52
* Consider your workload and set the values to match. If you're storing large values, set the timeout to a higher value.
53
53
* Set `AbortOnConnectFail` to false and let StackExchange.Redis reconnect for you.
54
-
* Use a single, long-lived `ConnectionMultiplexer` instance rather than creating a new connection for each request. For an example of how to manage a connection, see the `RedisConnection`` class in [Connect to the cache with RedisConnection](cache-dotnet-how-to-use-azure-redis-cache.md#connect-to-the-cache-with-redisconnection).
54
+
* Use a single, long-lived `ConnectionMultiplexer` instance rather than creating a new connection for each request.
55
55
* Set the `ConnectionMultiplexer.ClientName` property to an app instance unique name for diagnostic purposes.
56
56
* Use multiple `ConnectionMultiplexer` instances for custom workloads.
57
57
* You can follow this model if you have varying load in your application. For example:
#Customer intent: As a .NET developer, new to Azure Redis, I want to create a new Node.js app that uses Azure Managed Redis or Azure Cache for Redis.
11
11
---
12
-
# Quickstart: Use Azure Cache for Redis in .NET Core
12
+
13
+
# Quickstart: Use Azure Redis in .NET Core
13
14
14
15
In this quickstart, you incorporate Azure Cache for Redis into a .NET Core app to have access to a secure, dedicated cache that is accessible from any application within Azure. You specifically use the [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis) client with C# code in a .NET Core console app.
15
16
@@ -22,126 +23,99 @@ Clone the repo [https://github.com/Azure-Samples/azure-cache-redis-samples/tree/
22
23
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
### Install the Library for using Microsoft Entra ID Authentication
34
45
35
-
In your *appsettings.json* file, add the following:
46
+
The [Azure.StackExchange.Redis](https://www.nuget.org/packages/Microsoft.Azure.StackExchangeRedis) library contains the Microsoft Entra ID authentication method for connecting to Azure Redis services using Microsoft Entra ID. It's applicable to all Azure Cache for Redis, Azure Cache for Redis Enterprise, and Azure Managed Redis (Preview).
1. Replace "your_Azure_Redis_hostname" with your Azure Redis host name and port numbers. For example: `cache-name.region.redis.azure.net:10000` for Azure Managed Redis (preview), and `cache-name.redis.cache.windows.net:6380` for Azure Cache for Redis services.
52
+
---
44
53
45
-
1. Save the file.
54
+
## Connect to the cache using Microsoft Entra ID
46
55
47
-
## Connect to the cache with RedisConnection
56
+
1. Include the libraries in your code
48
57
49
-
In `RedisConnection.cs`, you see the `StackExchange.Redis` namespace has been added to the code. This is needed for the `RedisConnection` class.
The `RedisConnection` code ensures that there is always a healthy connection to the cache by managing the `ConnectionMultiplexer` instance from `StackExchange.Redis`. The `RedisConnection` class recreates the connection when a connection is lost and unable to reconnect automatically.
57
70
58
-
For more information, see [StackExchange.Redis](https://stackexchange.github.io/StackExchange.Redis/) and the code in a [GitHub repo](https://github.com/StackExchange/StackExchange.Redis).
1. Replace `<cache-hostname>` with your cache host name as it appears in the Overview section of the Resource menu in the Azure portal.
105
82
106
-
Cache items can be stored and retrieved by using the `StringSetAsync` and `StringGetAsync` methods.
83
+
For example, with Azure Managed Redis or the Enterprise tiers: _my-redis.eastus.azure.net:10000_
107
84
108
-
In the example, you can see the `Message` key is set to value. The app updated that cached value. The app also executed the `PING` and command.
85
+
1. Save the file.
109
86
110
-
### Work with .NET objects in the cache
87
+
For more information, see [StackExchange.Redis](https://stackexchange.github.io/StackExchange.Redis/) and the code in a [GitHub repo](https://github.com/StackExchange/StackExchange.Redis).
111
88
112
-
The Redis server stores most data as strings, but these strings can contain many types of data, including serialized binary data, which can be used when storing .NET objects in the cache.
89
+
::: zone-end
113
90
114
-
Azure Cache for Redis can cache both .NET objects and primitive data types, but before a .NET object can be cached it must be serialized.
91
+
::: zone pivot="azure-cache-redis"
115
92
116
-
This .NET object serialization is the responsibility of the application developer, and gives the developer flexibility in the choice of the serializer.
93
+
### To edit the _appsettings.json_ file
117
94
118
-
The following `Employee` class was defined in *Program.cs* so that the sample could also show how to get and set a serialized object:
95
+
1. Edit the _appsettings.json_ file. Then add the following content:
119
96
120
-
```csharp
121
-
classEmployee
122
-
{
123
-
publicstringId { get; set; }
124
-
publicstringName { get; set; }
125
-
publicintAge { get; set; }
126
-
127
-
publicEmployee(stringid, stringname, intage)
128
-
{
129
-
Id=id;
130
-
Name=name;
131
-
Age=age;
132
-
}
133
-
}
134
-
```
97
+
```json
98
+
"_redisHostName":"<cache-hostname>"
99
+
```
100
+
101
+
1. Replace `<cache-hostname>` with your cache host name as it appears in the Overview section of the Resource menu in the Azure portal.
102
+
103
+
For example, with Azure Cache for Redis: _my-redis.eastus.azure.net:6380_
104
+
105
+
1. Save the file.
106
+
107
+
For more information, see [StackExchange.Redis](https://stackexchange.github.io/StackExchange.Redis/) and the code in a [GitHub repo](https://github.com/StackExchange/StackExchange.Redis).
108
+
::: zone-end
135
109
136
110
## Run the sample
137
111
138
-
If you have opened any files, save them and build the app with the following command:
112
+
If you opened any files, save them, and build the app with the following command:
139
113
140
114
```dos
141
115
dotnet build
142
116
```
143
117
144
-
Run the app with the following command to test serialization of .NET objects:
118
+
To test serialization of .NET objects, run the app with the following command:
0 commit comments