@@ -86,9 +86,6 @@ $redis->get('greeting')->then(function (string $greeting) {
8686$redis->incr('invocation')->then(function (int $n) {
8787 echo 'This is invocation #' . $n . PHP_EOL;
8888});
89-
90- // end connection once all pending requests have been resolved
91- $redis->end();
9289```
9390
9491See also the [ examples] ( examples ) .
@@ -276,18 +273,18 @@ and keeps track of pending commands.
276273$redis = new Clue\React\Redis\RedisClient('localhost:6379');
277274
278275$redis->incr('hello');
279- $redis->end();
280276```
281277
282278Besides defining a few methods, this interface also implements the
283279` EventEmitterInterface ` which allows you to react to certain events as documented below.
284280
285- Internally, this class creates the underlying database connection only on
281+ Internally, this class creates the underlying connection to Redis only on
286282demand once the first request is invoked on this instance and will queue
287283all outstanding requests until the underlying connection is ready.
288- Additionally, it will only keep this underlying connection in an "idle" state
289- for 60s by default and will automatically close the underlying connection when
290- it is no longer needed.
284+ This underlying connection will be reused for all requests until it is closed.
285+ By default, idle connections will be held open for 1ms (0.001s) when not used.
286+ The next request will either reuse the existing connection or will automatically
287+ create a new underlying connection if this idle time is expired.
291288
292289From a consumer side this means that you can start sending commands to the
293290database right away while the underlying connection may still be
@@ -383,17 +380,17 @@ in seconds (or use a negative number to not apply a timeout) like this:
383380$redis = new Clue\React\Redis\RedisClient('localhost?timeout=0.5');
384381```
385382
386- By default, this method will keep "idle" connections open for 60s and will
387- then end the underlying connection. The next request after an "idle"
388- connection ended will automatically create a new underlying connection.
389- This ensure you always get a "fresh" connection and as such should not be
383+ By default, idle connections will be held open for 1ms (0.001s) when not used.
384+ The next request will either reuse the existing connection or will automatically
385+ create a new underlying connection if this idle time is expired .
386+ This ensures you always get a "fresh" connection and as such should not be
390387confused with a "keepalive" or "heartbeat" mechanism, as this will not
391388actively try to probe the connection. You can explicitly pass a custom
392389idle timeout value in seconds (or use a negative number to not apply a
393390timeout) like this:
394391
395392``` php
396- $redis = new Clue\React\Redis\RedisClient('localhost?idle=0.1 ');
393+ $redis = new Clue\React\Redis\RedisClient('localhost?idle=10.0 ');
397394```
398395
399396If you need custom DNS, proxy or TLS settings, you can explicitly pass a
0 commit comments