@@ -41,6 +41,10 @@ It is written in pure PHP and does not require any extensions.
41
41
This example runs a simple ` SELECT ` query and dumps all the records from a ` book ` table:
42
42
43
43
``` php
44
+ <?php
45
+
46
+ require __DIR__ . '/vendor/autoload.php';
47
+
44
48
$factory = new React\MySQL\Factory();
45
49
$connection = $factory->createLazyConnection('user:pass@localhost/bookstore');
46
50
@@ -54,8 +58,6 @@ $connection->query('SELECT * FROM book')->then(
54
58
echo 'Error: ' . $error->getMessage() . PHP_EOL;
55
59
}
56
60
);
57
-
58
- $connection->quit();
59
61
```
60
62
61
63
See also the [ examples] ( examples ) .
@@ -202,9 +204,11 @@ This method immediately returns a "virtual" connection implementing the
202
204
interface with your MySQL database. Internally, it lazily creates the
203
205
underlying database connection only on demand once the first request is
204
206
invoked on this instance and will queue all outstanding requests until
205
- the underlying connection is ready. Additionally, it will only keep this
206
- underlying connection in an "idle" state for 60s by default and will
207
- automatically end the underlying connection when it is no longer needed.
207
+ the underlying connection is ready. This underlying connection will be
208
+ reused for all requests until it is closed. By default, idle connections
209
+ will be held open for 1ms (0.001s) when not used. The next request will
210
+ either reuse the existing connection or will automatically create a new
211
+ underlying connection if this idle time is expired.
208
212
209
213
From a consumer side this means that you can start sending queries to the
210
214
database right away while the underlying connection may still be
@@ -277,17 +281,17 @@ in seconds (or use a negative number to not apply a timeout) like this:
277
281
$factory->createLazyConnection('localhost?timeout=0.5');
278
282
```
279
283
280
- By default, this method will keep "idle" connection open for 60s and will
281
- then end the underlying connection . The next request after an "idle"
282
- connection ended will automatically create a new underlying connection.
283
- This ensure you always get a "fresh" connection and as such should not be
284
- confused with a "keepalive" or "heartbeat" mechanism, as this will not
285
- actively try to probe the connection. You can explicitly pass a custom
286
- idle timeout value in seconds (or use a negative number to not apply a
287
- timeout) like this:
284
+ By default, idle connections will be held open for 1ms (0.001s) when not
285
+ used . The next request will either reuse the existing connection or will
286
+ automatically create a new underlying connection if this idle time is
287
+ expired. This ensures you always get a "fresh" connection and as such
288
+ should not be confused with a "keepalive" or "heartbeat" mechanism, as
289
+ this will not actively try to probe the connection. You can explicitly
290
+ pass a custom idle timeout value in seconds (or use a negative number to
291
+ not apply a timeout) like this:
288
292
289
293
``` php
290
- $factory->createLazyConnection('localhost?idle=0.1 ');
294
+ $factory->createLazyConnection('localhost?idle=10.0 ');
291
295
```
292
296
293
297
By default, the connection provides full UTF-8 support (using the
0 commit comments