@@ -86,9 +86,6 @@ $redis->get('greeting')->then(function (string $greeting) {
86
86
$redis->incr('invocation')->then(function (int $n) {
87
87
echo 'This is invocation #' . $n . PHP_EOL;
88
88
});
89
-
90
- // end connection once all pending requests have been resolved
91
- $redis->end();
92
89
```
93
90
94
91
See also the [ examples] ( examples ) .
@@ -276,18 +273,18 @@ and keeps track of pending commands.
276
273
$redis = new Clue\React\Redis\RedisClient('localhost:6379');
277
274
278
275
$redis->incr('hello');
279
- $redis->end();
280
276
```
281
277
282
278
Besides defining a few methods, this interface also implements the
283
279
` EventEmitterInterface ` which allows you to react to certain events as documented below.
284
280
285
- Internally, this class creates the underlying database connection only on
281
+ Internally, this class creates the underlying connection to Redis only on
286
282
demand once the first request is invoked on this instance and will queue
287
283
all 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.
291
288
292
289
From a consumer side this means that you can start sending commands to the
293
290
database 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:
383
380
$redis = new Clue\React\Redis\RedisClient('localhost?timeout=0.5');
384
381
```
385
382
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
390
387
confused with a "keepalive" or "heartbeat" mechanism, as this will not
391
388
actively try to probe the connection. You can explicitly pass a custom
392
389
idle timeout value in seconds (or use a negative number to not apply a
393
390
timeout) like this:
394
391
395
392
``` php
396
- $redis = new Clue\React\Redis\RedisClient('localhost?idle=0.1 ');
393
+ $redis = new Clue\React\Redis\RedisClient('localhost?idle=10.0 ');
397
394
```
398
395
399
396
If you need custom DNS, proxy or TLS settings, you can explicitly pass a
0 commit comments