Skip to content

Commit 5775a56

Browse files
committed
edits
1 parent b0b3be6 commit 5775a56

7 files changed

+226
-199
lines changed

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

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
---
2-
title: Use Azure Cache for Redis with Go
2+
title: 'Quickstart: Use Azure Cache for Redis with Go'
33
description: In this quickstart, you learn how to create a Go app that uses Azure Cache for Redis.
44

55

6-
76
ms.devlang: golang
87
ms.topic: quickstart
98
ms.date: 09/09/2021
109
ms.custom: mode-api, devx-track-go
1110
---
1211

13-
# Quickstart: Use Azure Cache for Redis with Go
12+
# Quickstart: Use Azure Cache for Redis with a Go app
1413

1514
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).
1615

@@ -22,24 +21,24 @@ If you want to go straight to the code, see the [Go quickstart sample](https://g
2221

2322
## Prerequisites
2423

25-
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
24+
- Azure subscription. [Create one for free](https://azure.microsoft.com/free/)
2625
- [Go](https://go.dev/doc/install) (preferably version 1.13 or later)
2726
- [Git](https://git-scm.com/downloads)
28-
- An HTTP client like [cURL](https://curl.se/)
27+
- An HTTP client like [curlL](https://curl.se/)
2928

3029
## Create a cache
3130

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

3433
[!INCLUDE [redis-cache-create](includes/redis-cache-access-keys.md)]
3534

36-
## Review the code (Optional)
35+
## Review the code (optional)
3736

38-
If you're interested in learning how the code works, you can review the following snippets. Otherwise, feel free to skip ahead to [Run the application](#run-the-application).
37+
If you're interested in learning how the code works, you can review the following code snippets. Feel free to skip ahead to [Run the application](#run-the-application).
3938

4039
The open source [go-redis](https://github.com/go-redis/redis) library is used to interact with Azure Cache for Redis.
4140

42-
The `main` function starts off by reading the host name and password (Access Key) for the Azure Cache for Redis instance.
41+
The `main` function starts by reading the host name and password (access key) for the Azure Cache for Redis instance.
4342

4443
```go
4544
func main() {
@@ -48,7 +47,7 @@ func main() {
4847
...
4948
```
5049
51-
Then, we establish connection with Azure Cache for Redis. We use [tls.Config](https://go.dev/pkg/crypto/tls/#Config)--Azure Cache for Redis only accepts secure connections with [TLS 1.2 as the minimum required version](cache-remove-tls-10-11.md).
50+
Then, you establish connection with Azure Cache for Redis. We use [tls.Config](https://go.dev/pkg/crypto/tls/#Config)--Azure Cache for Redis only accepts secure connections with [TLS 1.2 as the minimum required version](cache-remove-tls-10-11.md).
5251
5352
```go
5453
...
@@ -63,10 +62,10 @@ if err != nil {
6362
...
6463
```
6564
66-
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.
65+
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.
6766
6867
> [!NOTE]
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).
68+
>The [gorilla mux library](https://github.com/gorilla/mux) is used for routing (although it's not required, and using the standard library for this sample application is an option).
7069
>
7170
7271
```go
@@ -79,7 +78,7 @@ router.HandleFunc("/users/{userid}", uh.getUser).Methods(http.MethodGet)
7978
log.Fatal(http.ListenAndServe(":8080", router))
8079
```
8180
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.
81+
The `userHandler` struct encapsulates [redis.Client](https://pkg.go.dev/github.com/go-redis/redis/v8#Client). The `createUser` and `getUser` methods use redis.Client. For brevity, the code for these methods isn't included in this article.
8382
8483
- `createUser`: Accepts a JSON payload (that has user information) and saves it as a `HASH` in Azure Cache for Redis.
8584
- `getUser`: Fetches user info from `HASH` or returns an HTTP `404` response if it's not found.
@@ -126,22 +125,24 @@ Start by cloning the application on GitHub:
126125
127126
The application accepts connectivity and credentials in the form of environment variables.
128127
129-
1. In the [Azure portal](https://portal.azure.com/), get the host name and access keys for the Azure Cache for Redis instance.
128+
1. In the [Azure portal](https://portal.azure.com/), get the host name and access key for the instance of Azure Cache for Redis.
130129
131-
1. Set them to the respective environment variables:
130+
1. Set the host name and access key to the following environment variables:
132131
133132
```console
134133
set REDIS_HOST=<Host name>:<port> (for example, <name of cache>.redis.cache.windows.net:6380)
135134
set REDIS_PASSWORD=<Primary Access Key>
136135
```
137136
138-
1. In the terminal window, change to the correct folder. For example:
137+
1. In the terminal, go to the folder you created for the samples:
138+
139+
For example:
139140
140141
```console
141142
cd "C:\git-samples\azure-redis-cache-go-quickstart"
142143
```
143144
144-
1. In the terminal, run the following command to start the application.
145+
1. In the terminal, start the application by using this command:
145146
146147
```console
147148
go run main.go
@@ -151,23 +152,23 @@ The HTTP server starts on port `8080`.
151152
152153
## Test the application
153154
154-
1. Create a few user entries.
155+
1. Create a few user entries.
155156
156-
The following example uses cURL:
157+
The following example uses curl:
157158
158159
```bash
159160
curl -i -X POST -d '{"id":"1","name":"foo1", "email":"[email protected]"}' localhost:8080/users/
160161
curl -i -X POST -d '{"id":"2","name":"foo2", "email":"[email protected]"}' localhost:8080/users/
161162
curl -i -X POST -d '{"id":"3","name":"foo3", "email":"[email protected]"}' localhost:8080/users/
162163
```
163164
164-
1. Fetch an existing user by using the value for the `id`:
165+
1. Fetch an existing user by using the value for `id`:
165166
166167
```bash
167168
curl -i localhost:8080/users/1
168169
```
169170
170-
The output is JSON response that is similar to this example:
171+
The output is a JSON response that's similar to this example:
171172
172173
```json
173174
{
@@ -177,7 +178,7 @@ The HTTP server starts on port `8080`.
177178
}
178179
```
179180
180-
1. If you try to fetch a user who doesn't exist, you get an HTTP `404`.
181+
1. If you try to fetch a user who doesn't exist, you get an HTTP `404` error message.
181182
182183
For example:
183184
@@ -199,5 +200,6 @@ The HTTP server starts on port `8080`.
199200
200201
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.
201202
202-
> [!div class="nextstepaction"]
203-
> [Create a simple ASP.NET web app that uses an Azure Cache for Redis.](./cache-web-app-howto.md)
203+
## Related content
204+
205+
- [Create a simple ASP.NET web app that uses Azure Cache for Redis.](./cache-web-app-howto.md)

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ ms.devlang: java
1010
ms.custom: devx-track-java, devx-track-javaee, mode-api, mvc, devx-track-extended-java
1111
---
1212

13-
# Quickstart: Use Azure Cache for Redis in Java
13+
# Quickstart: Use Azure Cache for Redis in a Java app
1414

1515
In this quickstart, you incorporate Azure Cache for Redis into a Java app by using the [Jedis](https://github.com/xetorthio/jedis) Redis client. Your cache is a secure, dedicated cache that is accessible from any application within Azure.
1616

1717
## Skip to the code
1818

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.
19+
This quickstart uses the Maven archetype feature to generate scaffolding for the app. The quickstart describes how to modify the generated code to end up with a working sample app.
2020

2121
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.
2222

@@ -33,7 +33,7 @@ If you want to go straight to the code, see the [Java quickstart sample](https:/
3333

3434
## Set up the working environment
3535

36-
Depending on your operating system, add environment variables for your **Host name** and **Primary access key** that you noted previously. Open a command prompt, or a terminal window, and set up the following values:
36+
Depending on your operating system, add environment variables for host name and primary access key that you noted earrlier. In a command prompt or a terminal window, set up the following values:
3737

3838
### [Linux](#tab/bash)
3939

@@ -53,16 +53,16 @@ set REDISCACHEKEY=<your-primary-access-key>
5353

5454
Replace the placeholders with the following values:
5555

56-
- `<your-host-name>`: The DNS host name, obtained from the *Properties* section of your Azure Cache for Redis resource in the Azure portal.
57-
- `<your-primary-access-key>`: The primary access key, obtained from the *Access keys* section of your Azure Cache for Redis resource in the Azure portal.
56+
- `<your-host-name>`: The DNS host name, obtained from the **Properties** section of your Azure Cache for Redis resource in the Azure portal.
57+
- `<your-primary-access-key>`: The primary access key, obtained from the **Access keys** section of your Azure Cache for Redis resource in the Azure portal.
5858

5959
## Understand the Java sample
6060

6161
In this sample, you use Maven to run the quickstart app.
6262

63-
1. Change to the new *redistest* project directory.
63+
1. Go to the new *redistest* project directory.
6464

65-
1. Open the *pom.xml* file. In the file, you see a dependency for [Jedis](https://github.com/xetorthio/jedis):
65+
1. Open the *pom.xml* file. In the file, verify that a dependency for [Jedis](https://github.com/xetorthio/jedis) appears:
6666

6767
```xml
6868
<dependency>
@@ -76,7 +76,7 @@ In this sample, you use Maven to run the quickstart app.
7676

7777
1. Close the *pom.xml* file.
7878

79-
1. Open *App.java* and see the code with the following code:
79+
1. Open *App.java* and verify that the following code appears:
8080

8181
```java
8282
package example.demo;
@@ -103,7 +103,7 @@ In this sample, you use Maven to run the quickstart app.
103103
.ssl(useSsl)
104104
.build());
105105

106-
// Perform cache operations using the cache connection object...
106+
// Perform cache operations by using the cache connection object.
107107

108108
// Simple PING command
109109
System.out.println( "\nCache Command : Ping" );
@@ -129,13 +129,13 @@ In this sample, you use Maven to run the quickstart app.
129129
}
130130
```
131131

132-
This code shows you how to connect to an Azure Cache for Redis instance using the cache host name and key environment variables. The code also stores and retrieves a string value in the cache. The `PING` and `CLIENT LIST` commands are also executed.
132+
This code shows you how to connect to an Azure Cache for Redis instance by using the cache host name and key environment variables. The code also stores and retrieves a string value in the cache. The `PING` and `CLIENT LIST` commands are also executed.
133133

134-
1. Close the *App.java*.
134+
1. Close *App.java*.
135135

136136
## Build and run the app
137137

138-
1. First, if you haven't already, you must set the environment variables as noted previously.
138+
1. Set the environment variables as noted earlier:
139139

140140
### [Linux](#tab/bash)
141141

@@ -153,7 +153,7 @@ In this sample, you use Maven to run the quickstart app.
153153

154154
---
155155

156-
1. Execute the following Maven command to build and run the app:
156+
1. To build and run the app, run the following Maven command:
157157

158158
### [Linux](#tab/bash)
159159

@@ -171,7 +171,7 @@ In this sample, you use Maven to run the quickstart app.
171171

172172
---
173173

174-
In the following output, you can see that the `Message` key previously had a cached value. The value was updated to a new value using `jedis.set`. The app also executed the `PING` and `CLIENT LIST` commands.
174+
In the following output, you can see that the `Message` key previously had a cached value. The value was updated to a new value by using `jedis.set`. The app also executed the `PING` and `CLIENT LIST` commands.
175175

176176
```output
177177
Cache Command : Ping
@@ -196,8 +196,6 @@ Cache Response : id=777430 addr= :58989 fd=22 name= age=1 idle=0 fla
196196

197197
## Related content
198198

199-
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.
200-
201199
- [Development](cache-best-practices-development.md)
202200
- [Connection resilience](cache-best-practices-connection.md)
203201
- [Azure Cache for Redis with Jakarta EE](/azure/developer/java/ee/how-to-deploy-java-liberty-jcache)

0 commit comments

Comments
 (0)