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
Because adding a `try-with-resources` block for each command can be cumbersome, consider using `JedisPooled` as an easier way to pool connections. `JedisPooled`, added in Jedis version 4.0.0, provides capabilities similar to `JedisPool` but with a more straightforward API.
System.out.println(jedis.get("foo")); // prints "bar"
359
+
```
322
360
323
-
As mentioned in the previous section, use `JedisPool` or `JedisPooled` to create a connection pool.
324
-
`JedisPooled`, added in Jedis version 4.0.0, provides capabilities similar to `JedisPool` but with a more straightforward API.
325
361
A connection pool holds a specified number of connections, creates more connections when necessary, and terminates them when they are no longer needed.
326
362
327
363
Here is a simplified connection lifecycle in a pool:
The following sections explain how to handle situations that may occur
409
+
in your production environment.
410
+
370
411
### Timeouts
371
412
372
413
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:
A typical approach with Lettuce is to create a single `RedisClient` instance and reuse it to establish connections to your Redis server(s).
236
236
These connections are multiplexed; that is, multiple commands can be run concurrently over a single or a small set of connections, making explicit pooling less practical.
237
+
See
238
+
[Connection pools and multiplexing]({{< relref "/develop/connect/clients/pools-and-muxing" >}})
239
+
for more information.
237
240
238
241
Lettuce provides pool config to be used with Lettuce asynchronous connection methods.
0 commit comments