Skip to content

Commit fcf918f

Browse files
committed
edits
1 parent 47f966c commit fcf918f

13 files changed

+153
-217
lines changed

articles/azure-cache-for-redis/cache-dotnet-core-quickstart.md

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ ms.custom: devx-track-csharp, mvc, mode-other, devx-track-dotnet
99
ms.topic: quickstart
1010
ms.date: 03/25/2022
1111
---
12+
1213
# Quickstart: Use Azure Cache for Redis in .NET Core
1314

1415
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.
1516

16-
## Skip to the code on GitHub
17+
## Skip to the code
18+
19+
This article describes how to create an app by using the Azure portal and then modify the code to end up with a working sample app.
1720

18-
Clone the repo [https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/quickstart/dotnet-core](https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/quickstart/dotnet-core) on GitHub.
21+
If you want to go straight to the code, see the [.NET Core sample](https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/quickstart/dotnet-core) on GitHub.
1922

2023
## Prerequisites
2124

@@ -28,33 +31,33 @@ Clone the repo [https://github.com/Azure-Samples/azure-cache-redis-samples/tree/
2831

2932
[!INCLUDE [redis-cache-access-keys](includes/redis-cache-access-keys.md)]
3033

31-
Make a note of the **HOST NAME** and the **Primary** access key. You'll use these values later to construct the *CacheConnection* secret.
34+
Make a note of the values for **HOST NAME** and the **Primary** access key. You'll use these values later to construct the `CacheConnection` secret.
3235

3336
## Add a local secret for the connection string
3437

35-
In your command window, execute the following command to store a new secret named *CacheConnection*, after replacing the placeholders (including angle brackets) for your cache name and primary access key:
38+
In your command window, execute the following command to store a new secret named *CacheConnection* after you replac the placeholders (including angle brackets) with your cache name (`<cache name>`) and primary access key (`<primary-access-key>`):
3639

3740
```dos
3841
dotnet user-secrets set CacheConnection "<cache name>.redis.cache.windows.net,abortConnect=false,ssl=true,allowAdmin=true,password=<primary-access-key>"
3942
```
4043

41-
## Connect to the cache with RedisConnection
44+
## Connect to the cache by using RedisConnection
4245

43-
The connection to your cache is managed by the `RedisConnection` class. The connection is first made in this statement from `Program.cs`:
46+
The connection to your cache is managed by the `RedisConnection` class. First, you make the connection in this statement from *Program.cs*:
4447

4548
```csharp
4649
_redisConnection = await RedisConnection.InitializeAsync(connectionString: configuration["CacheConnection"].ToString());
4750

4851
```
4952

50-
In `RedisConnection.cs`, you see the `StackExchange.Redis` namespace has been added to the code. This is needed for the `RedisConnection` class.
53+
In *RedisConnection.cs*, the `StackExchange.Redis` namespace has been added to the code. The namespace is required for the `RedisConnection` class.
5154

5255
```csharp
5356
using StackExchange.Redis;
5457

5558
```
56-
<!-- Is this right Philo -->
57-
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.
59+
60+
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 re-creates the connection when a connection is lost and unable to reconnect automatically.
5861

5962
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).
6063

@@ -63,7 +66,9 @@ For more information, see [StackExchange.Redis](https://stackexchange.github.io/
6366
## Executing cache commands
6467

6568
In `program.cs`, you can see the following code for the `RunRedisCommandsAsync` method in the `Program` class for the console application:
69+
6670
<!-- Replaced this code with lines 57-81 from dotnet-core/Program.cs -->
71+
6772
```csharp
6873
private static async Task RunRedisCommandsAsync(string prefix)
6974
{
@@ -104,19 +109,19 @@ private static async Task RunRedisCommandsAsync(string prefix)
104109

105110
```
106111

107-
Cache items can be stored and retrieved by using the `StringSetAsync` and `StringGetAsync` methods.
112+
You can store and retrieve cache items by using the `StringSetAsync` and `StringGetAsync` methods.
108113

109-
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.
114+
In the example, you can see the `Message` key is set to a value. The app updated that cached value. The app also executed the `PING` and command.
110115

111116
### Work with .NET objects in the cache
112117

113-
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.
118+
The Redis server stores most data in string format. The strings can contain many types of data, including serialized binary data. You can use serialized binary data when you store .NET objects in the cache.
114119

115-
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.
120+
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.
116121

117-
This .NET object serialization is the responsibility of the application developer, and gives the developer flexibility in the choice of the serializer.
122+
The .NET object serialization is the responsibility of the application developer. The object serialization gives the developer flexibility in their choice of the serializer.
118123

119-
The following `Employee` class was defined in *Program.cs* so that the sample could also show how to get and set a serialized object :
124+
The following `Employee` class was defined in *Program.cs* so that the sample could also show how to get and set a serialized object:
120125

121126
```csharp
122127
class Employee
@@ -136,7 +141,7 @@ class Employee
136141

137142
## Run the sample
138143

139-
If you have opened any files, save them and build the app with the following command:
144+
If you opened any files, save the files. Then, build the app by using the following command:
140145

141146
```dos
142147
dotnet build
@@ -150,28 +155,11 @@ dotnet run
150155

151156
:::image type="content" source="media/cache-dotnet-core-quickstart/cache-console-app-complete.png" alt-text="Console app completed":::
152157

153-
## Clean up resources
154-
155-
If you continue to use this quickstart, you can keep the resources you created and reuse them.
156-
157-
Otherwise, if you're finished with the quickstart sample application, you can delete the Azure resources created in this quickstart to avoid charges.
158-
159-
> [!IMPORTANT]
160-
> Deleting a resource group is irreversible and that the resource group and all the resources in it are permanently deleted. Make sure that you do not accidentally delete the wrong resource group or resources. If you created the resources for hosting this sample inside an existing resource group that contains resources you want to keep, you can delete each resource individually on the left instead of deleting the resource group.
161-
>
162-
### To delete a resource group
163-
164-
1. Sign in to the [Azure portal](https://portal.azure.com) and select **Resource groups**.
165-
166-
1. In the **Filter by name...** textbox, type the name of your resource group. The instructions for this article used a resource group named *TestResources*. On your resource group in the result list, select **...** then **Delete resource group**.
167-
168-
:::image type="content" source="media/cache-dotnet-core-quickstart/cache-delete-resource-group.png" alt-text="Delete":::
169-
170-
1. You'll be asked to confirm the deletion of the resource group. Type the name of your resource group to confirm, and select **Delete**.
158+
<!-- Clean up include -->
171159

172-
After a few moments, the resource group and all of its contained resources are deleted.
160+
[!INCLUDE [cache-delete-resource-group](includes/cache-delete-resource-group.md)]
173161

174-
## Next steps
162+
## Related content
175163

176164
- [Connection resilience](cache-best-practices-connection.md)
177165
- [Best Practices Development](cache-best-practices-development.md)

articles/azure-cache-for-redis/cache-go-get-started.md

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ ms.custom: mode-api, devx-track-go
1414

1515
In this article, you learn how to build a REST API in Go that stores and retrieves user information backed by a [HASH](https://redis.io/topics/data-types-intro#redis-hashes) data structure in [Azure Cache for Redis](./cache-overview.md).
1616

17-
## Skip to the code on GitHub
17+
## Skip to the code
1818

19-
If you want to skip straight to the code, see the [Go quickstart](https://github.com/Azure-Samples/azure-redis-cache-go-quickstart/) on GitHub.
19+
This article describes how to create an app by using the Azure portal and then modify the code to end up with a working sample app.
20+
21+
If you want to go straight to the code, see the [Go quickstart sample](https://github.com/Azure-Samples/azure-redis-cache-go-quickstart/) on GitHub.
2022

2123
## Prerequisites
2224

2325
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
24-
- [Go](https://go.dev/doc/install) (preferably version 1.13 or above)
26+
- [Go](https://go.dev/doc/install) (preferably version 1.13 or later)
2527
- [Git](https://git-scm.com/downloads)
26-
- An HTTP client such [curl](https://curl.se/)
28+
- An HTTP client like [cURL](https://curl.se/)
2729

28-
## Create an Azure Cache for Redis instance
30+
## Create a cache
2931

3032
[!INCLUDE [redis-cache-create](~/reusable-content/ce-skilling/azure/includes/azure-cache-for-redis/includes/redis-cache-create.md)]
3133

@@ -64,7 +66,7 @@ if err != nil {
6466
If the connection is successful, [HTTP handlers](https://go.dev/pkg/net/http/#HandleFunc) are configured to handle `POST` and `GET` operations and the HTTP server is started.
6567
6668
> [!NOTE]
67-
> [gorilla mux library](https://github.com/gorilla/mux) is used for routing (although it's not strictly necessary and we could have gotten away by using the standard library for this sample application).
69+
>The [gorilla mux library](https://github.com/gorilla/mux) is used for routing (although it's not strictly necessary, and using the standard library for this sample application is an option).
6870
>
6971
7072
```go
@@ -77,10 +79,10 @@ router.HandleFunc("/users/{userid}", uh.getUser).Methods(http.MethodGet)
7779
log.Fatal(http.ListenAndServe(":8080", router))
7880
```
7981
80-
`userHandler` struct encapsulates a [redis.Client](https://pkg.go.dev/github.com/go-redis/redis/v8#Client), which is used by the `createUser`, `getUser` methods - code for these methods isn't included for brevity.
82+
The `userHandler` struct encapsulates a [redis.Client](https://pkg.go.dev/github.com/go-redis/redis/v8#Client). The `createUser` and `getUser` methods use the redis.Client. For brevity, the code for these methods isn't included in this article.
8183
82-
- `createUser`: accepts a JSON payload (containing user information) and saves it as a `HASH` in Azure Cache for Redis.
83-
- `getUser`: fetches user info from `HASH` or returns an HTTP `404` response if not found.
84+
- `createUser`: Accepts a JSON payload (that has user information) and saves it as a `HASH` in Azure Cache for Redis.
85+
- `getUser`: Fetches user info from `HASH` or returns an HTTP `404` response if it's not found.
8486
8587
```go
8688
type userHandler struct {
@@ -100,15 +102,15 @@ func (uh userHandler) getUser(rw http.ResponseWriter, r *http.Request) {
100102
101103
## Clone the sample application
102104
103-
Start by cloning the application from GitHub.
105+
Start by cloning the application on GitHub:
104106
105-
1. Open a command prompt and create a new folder named `git-samples`.
107+
1. At the command prompt for your computer's root directory, create a new folder named `git-samples`:
106108
107109
```bash
108110
md "C:\git-samples"
109111
```
110112
111-
1. Open a git terminal window, such as git bash. Use the `cd` command to change to the new folder where you want to clone the sample app.
113+
1. Open a git terminal window, such as by using Git Bash. Use the `cd` command to go to the new folder to clone the sample app.
112114
113115
```bash
114116
cd "C:\git-samples"
@@ -124,12 +126,12 @@ Start by cloning the application from GitHub.
124126
125127
The application accepts connectivity and credentials in the form of environment variables.
126128
127-
1. Fetch the **Host name** and **Access Keys** (available via Access Keys) for Azure Cache for Redis instance in the [Azure portal](https://portal.azure.com/)
129+
1. In the [Azure portal](https://portal.azure.com/), get the host name and access keys for the Azure Cache for Redis instance.
128130
129131
1. Set them to the respective environment variables:
130132
131133
```console
132-
set REDIS_HOST=<Host name>:<port> (e.g. <name of cache>.redis.cache.windows.net:6380)
134+
set REDIS_HOST=<Host name>:<port> (for example, <name of cache>.redis.cache.windows.net:6380)
133135
set REDIS_PASSWORD=<Primary Access Key>
134136
```
135137
@@ -145,25 +147,27 @@ The application accepts connectivity and credentials in the form of environment
145147
go run main.go
146148
```
147149
148-
The HTTP server will start on port `8080`.
150+
The HTTP server starts on port `8080`.
149151
150152
## Test the application
151153
152-
1. Create a few user entries. The below example uses curl:
154+
1. Create a few user entries.
155+
156+
The following example uses cURL:
153157
154158
```bash
155159
curl -i -X POST -d '{"id":"1","name":"foo1", "email":"[email protected]"}' localhost:8080/users/
156160
curl -i -X POST -d '{"id":"2","name":"foo2", "email":"[email protected]"}' localhost:8080/users/
157161
curl -i -X POST -d '{"id":"3","name":"foo3", "email":"[email protected]"}' localhost:8080/users/
158162
```
159163
160-
1. Fetch an existing user with its `id`:
164+
1. Fetch an existing user by using the value for the `id`:
161165
162166
```bash
163167
curl -i localhost:8080/users/1
164168
```
165169
166-
You should get JSON response as such:
170+
You should get a JSON response that is similar to this example:
167171
168172
```json
169173
{
@@ -173,7 +177,9 @@ The HTTP server will start on port `8080`.
173177
}
174178
```
175179
176-
1. If you try to fetch a user who doesn't exist, you get an HTTP `404`. For example:
180+
1. If you try to fetch a user who doesn't exist, you get an HTTP `404`.
181+
182+
For example:
177183
178184
```bash
179185
curl -i localhost:8080/users/100
@@ -185,23 +191,11 @@ The HTTP server will start on port `8080`.
185191
Content-Length: 0
186192
```
187193
188-
## Clean up resources
189-
190-
If you're finished with the Azure resource group and resources you created in this quickstart, you can delete them to avoid charges.
191-
192-
> [!IMPORTANT]
193-
> Deleting a resource group is irreversible, and the resource group and all the resources in it are permanently deleted. If you created your Azure Cache for Redis instance in an existing resource group that you want to keep, you can delete just the cache by selecting **Delete** from the cache **Overview** page.
194-
195-
To delete the resource group and its Redis Cache for Azure instance:
196-
197-
1. From the [Azure portal](https://portal.azure.com), search for and select **Resource groups**.
198-
1. In the **Filter by name** text box, enter the name of the resource group that contains your cache instance, and then select it from the search results.
199-
1. On your resource group page, select **Delete resource group**.
200-
1. Type the resource group name, and then select **Delete**.
194+
<!-- Clean up include -->
201195
202-
![Delete your resource group for Azure Cache for Redis](./media/cache-python-get-started/delete-your-resource-group-for-azure-cache-for-redis.png)
196+
[!INCLUDE [cache-delete-resource-group](includes/cache-delete-resource-group.md)]
203197
204-
## Next steps
198+
## Related content
205199
206200
In this quickstart, you learned how to get started using Go with Azure Cache for Redis. You configured and ran a simple REST API-based application to create and get user information backed by a Redis `HASH` data structure.
207201

articles/azure-cache-for-redis/cache-java-get-started.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ In this quickstart, you incorporate Azure Cache for Redis into a Java app by usi
1616

1717
## Skip to the code
1818

19-
Clone the repo on GitHub: [Java quickstart](https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/quickstart/java)
19+
This article describes how to create an app by using the Azure portal and then modify the code to end up with a working sample app.
20+
21+
If you want to go straight to the code, see the [Java quickstart sample](https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/quickstart/java) on GitHub.
2022

2123
## Prerequisites
2224

2325
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
2426
- [Apache Maven](https://maven.apache.org/download.cgi)
2527

26-
## Create an Azure Cache for Redis
28+
## Create a cache
2729

2830
[!INCLUDE [redis-cache-create](~/reusable-content/ce-skilling/azure/includes/azure-cache-for-redis/includes/redis-cache-create.md)]
2931

@@ -188,27 +190,11 @@ Cache Command : CLIENT LIST
188190
Cache Response : id=777430 addr= :58989 fd=22 name= age=1 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 ow=0 owmem=0 events=r cmd=client numops=6
189191
```
190192

191-
## Clean up resources
192-
193-
If you continue to use the quickstart code, you can keep the resources created in this quickstart and reuse them.
194-
195-
Otherwise, if you're finished with the quickstart sample application, you can delete the Azure resources created in this quickstart to avoid charges.
196-
197-
> [!IMPORTANT]
198-
> Deleting a resource group is irreversible and that the resource group and all the resources in it are permanently deleted. Make sure that you do not accidentally delete the wrong resource group or resources. If you created the resources for hosting this sample inside an existing resource group that contains resources you want to keep, you can delete each resource individually instead of deleting the resource group.
199-
>
200-
201-
1. Sign in to the [Azure portal](https://portal.azure.com) and select **Resource groups**.
202-
203-
1. In the **Filter by name** textbox, type the name of your resource group. The instructions for this article used a resource group named *TestResources*. On your resource group in the result list, select **...** then **Delete resource group**.
204-
205-
:::image type="content" source="media/cache-java-get-started/azure-cache-redis-delete-resource-group.png" alt-text="Screenshot of the Azure portal that shows the Resource groups page with the Delete resource group button highlighted." lightbox="media/cache-java-get-started/azure-cache-redis-delete-resource-group.png":::
206-
207-
1. Type the name of your resource group to confirm deletion and then select **Delete**.
193+
<!-- Clean up include -->
208194

209-
After a few moments, the resource group and all of its contained resources are deleted.
195+
[!INCLUDE [cache-delete-resource-group](includes/cache-delete-resource-group.md)]
210196

211-
## Next steps
197+
## Related content
212198

213199
In this quickstart, you learned how to use Azure Cache for Redis from a Java application. Continue to the next quickstart to use Azure Cache for Redis with an ASP.NET web app.
214200

0 commit comments

Comments
 (0)