Skip to content

Commit 697f6ef

Browse files
Merge pull request #2032 from redis/DOC-5643-client-close-calls
DOC-5643 added close/quit details to client landing pages
2 parents 010bd18 + c85d789 commit 697f6ef

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

content/develop/clients/go/_index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ fmt.Printf("Model: %v, Brand: %v, Type: %v, Price: $%v\n",
156156
// >>> Model: Deimos, Brand: Ergonom, Type: Enduro bikes, Price: $4972
157157
```
158158

159+
Close the connection when you're done using `client.Close()`. In the
160+
common case where you want to close the connection at the end of the
161+
function where you opened it, you may find it convenient to use a `defer`
162+
statement right after connecting:
163+
164+
```go
165+
func main() {
166+
client := redis.NewClient(&redis.Options{
167+
...
168+
})
169+
defer client.Close()
170+
...
171+
}
172+
```
173+
159174
## Observability
160175

161176
`go-redis` supports [OpenTelemetry](https://opentelemetry.io/) instrumentation.

content/develop/clients/jedis/_index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ To include `Jedis` as a dependency in your application, edit the dependency file
5858

5959
## Connect and test
6060

61-
The following code opens a basic connection to a local Redis server:
61+
The following code opens a basic connection to a local Redis server
62+
and closes it after use.
6263

6364
```java
6465
package org.example;

content/develop/clients/lettuce/_index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ To build from source, see the instructions on the [Lettuce source code GitHub re
5555
## Connect and test
5656

5757
Connect to a local server using the following code. This example
58-
also stores and retrieves a simple string value to test the connection.
58+
also stores and retrieves a simple string value to test the connection
59+
and closes the connection after use.
5960

6061
```java
6162
import io.lettuce.core.*;

content/develop/clients/nodejs/_index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ createClient({
8686
```
8787
To check if the client is connected and ready to send commands, use `client.isReady`, which returns a Boolean. `client.isOpen` is also available. This returns `true` when the client's underlying socket is open, and `false` when it isn't (for example, when the client is still connecting or reconnecting after a network error).
8888

89+
When you have finished using a connection, close it with `client.quit()`.
90+
91+
```js
92+
await client.quit();
93+
```
94+
8995
## More information
9096

9197
The [`node-redis` website](https://redis.js.org/) has more examples.

content/develop/clients/redis-py/_index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ r.hgetall('user-session:123')
8282
# {'surname': 'Smith', 'name': 'John', 'company': 'Redis', 'age': '29'}
8383
```
8484

85+
Close the connection when you're done.
86+
87+
```python
88+
r.close()
89+
```
90+
8591
## More information
8692

8793
The [`redis-py`](https://redis.readthedocs.io/en/stable/index.html) website

0 commit comments

Comments
 (0)