Skip to content

Commit 9cd341b

Browse files
committed
Add docs for max uses
1 parent 8b4f41c commit 9cd341b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

docs/pages/apis/pool.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ type Config = {
5151
// where you don't want to wait for your clients to go idle before your process exits.
5252
allowExitOnIdle?: boolean
5353

54+
// number of times a client can be checked out from the pool before it is
55+
// disconnected and a new client is created in its place.
56+
// the default is Infinity which means a client will never be automatically destroyed outside of other lifecycle things
57+
// like manually removing it, it timing out due to idelness, etc...
58+
maxUses?: number
59+
5460
// Sets a max overall life for the connection.
5561
// A value of 60 would evict connections that have been around for over 60 seconds,
5662
// regardless of whether they are idle. It's useful to force rotation of connection pools through
@@ -77,7 +83,7 @@ const pool = new Pool({
7783
max: 20,
7884
idleTimeoutMillis: 30000,
7985
connectionTimeoutMillis: 2000,
80-
maxLifetimeSeconds: 60
86+
maxLifetimeSeconds: 60,
8187
})
8288
```
8389

@@ -89,7 +95,7 @@ import { Pool } from 'pg'
8995
const pool = new Pool({
9096
onConnect: async (client) => {
9197
await client.query('SET search_path TO my_schema')
92-
}
98+
},
9399
})
94100
```
95101

0 commit comments

Comments
 (0)