Skip to content

Commit b2f5c99

Browse files
DOC-5064 finished checklist and added some new sections
1 parent e0c14cb commit b2f5c99

File tree

2 files changed

+52
-8
lines changed

2 files changed

+52
-8
lines changed

content/develop/clients/jedis/produsage.md

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,62 @@ title: Production usage
1515
weight: 6
1616
---
1717

18-
The following sections explain how to handle situations that may occur
19-
in your production environment. Use the checklist below to record your
18+
This guide offers recommendations to get the best reliability and
19+
performance in your production environment.
20+
21+
## Checklist
22+
23+
Each item in the checklist below links to the section
24+
for a recommendation. Use the checklist icons to record your
2025
progress in implementing the recommendations.
2126

27+
[](#client-side-caching)
2228
{{< checklist "prodlist" >}}
29+
{{< checklist-item "#connection-pooling" >}}Connection pooling{{< /checklist-item >}}
30+
{{< checklist-item "#client-side-caching" >}}Client-side caching{{< /checklist-item >}}
2331
{{< checklist-item "#timeouts" >}}Timeouts{{< /checklist-item >}}
2432
{{< checklist-item "#exception-handling" >}}Exception handling{{< /checklist-item >}}
25-
{{< checklist-item "#general-exceptions" >}}General exceptions{{< /checklist-item >}}
26-
{{< checklist-item "#dns-cache-and-redis" >}}DNS cache and Redis{{< /checklist-item >}}
2733
{{< checklist-item "#dns-cache-and-redis" >}}DNS cache and Redis{{< /checklist-item >}}
2834
{{< /checklist >}}
2935

36+
## Recommendations
37+
38+
The sections below offer recommendations for your production environment. Some
39+
of them may not apply to your particular use case.
40+
41+
### Connection pooling
3042

43+
Example code often opens a connection at the start, demonstrates a feature,
44+
and then closes the connection at the end. However, production code
45+
typically uses connections many times intermittently. Repeatedly opening
46+
and closing connections has a performance overhead.
47+
48+
Use [connection pooling]({{< relref "/develop/clients/pools-and-muxing" >}})
49+
to avoid the overhead of opening and closing connections without having to
50+
write your own code to cache and reuse open connections. See
51+
[Connect with a connection pool]({{< relref "/develop/clients/jedis/connect#connect-with-a-connection-pool" >}})
52+
to learn how to use this technique with Jedis.
53+
54+
### Client-side caching
55+
56+
[Client-side caching]({{< relref "/develop/clients/client-side-caching" >}})
57+
involves storing the results from read-only commands in a local cache. If the
58+
same command is executed again later, the result can be obtained from the cache,
59+
without contacting the server. This improves command execution time on the client,
60+
while also reducing network traffic and server load. See
61+
[Connect using client-side caching]({{< relref "/develop/clients/jedis/connect#connect-using-client-side-caching" >}})
62+
for more information and example code.
3163

3264
### Timeouts
3365

34-
To set a timeout for a connection, use the `JedisPooled` or `JedisPool` constructor with the `timeout` parameter, or use `JedisClientConfig` with the `socketTimeout` and `connectionTimeout` parameters:
66+
If a network or server error occurs while your code is opening a
67+
connection or issuing a command, it can end up hanging indefinitely.
68+
You can prevent this from happening by setting timeouts for socket
69+
reads and writes and for opening connections.
70+
71+
To set a timeout for a connection, use the `JedisPooled` or `JedisPool` constructor with the `timeout` parameter, or use `JedisClientConfig` with the `socketTimeout` and `connectionTimeout` parameters.
72+
(The socket timeout is the maximum time allowed for reading or writing data while executing a
73+
command. The connection timeout is the maximum time allowed for establishing a new connection.)
3574

3675
```java
3776
HostAndPort hostAndPort = new HostAndPort("localhost", 6379);
@@ -47,7 +86,13 @@ JedisPooled jedisWithTimeout = new JedisPooled(hostAndPort,
4786

4887
### Exception handling
4988

50-
The Jedis Exception Hierarchy is rooted on `JedisException`, which implements `RuntimeException`, and are therefore all unchecked exceptions.
89+
Redis handles many errors using return values from commands, but there
90+
are also situations where exceptions can be thrown. In production code,
91+
you should handle
92+
93+
The Jedis exception hierarchy is rooted on `JedisException`, which implements
94+
`RuntimeException`. All exceptions in the hierarchy are therefore unchecked
95+
exceptions.
5196

5297
```
5398
JedisException

layouts/shortcodes/checklist-item.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<li>
2-
<select name="varp"
3-
onchange="clChange('prodlist')">
2+
<select onchange="clChange('prodlist')">
43
<option value="R">&#x274C;</option>
54
<option value="G">&#9989;</option>
65
<option value="A">&#x1F50D;</option>

0 commit comments

Comments
 (0)