Public sqlite db options: MaxOpenConns, MaxIdleConns, ConnMaxLifetime. (#310)

* Public sqlite db options: MaxOpenConns, MaxIdleConns, ConnMaxLifetime.

* Update sqlite3/README.md.

* Add comment lines for the public options.

* Typo

* Set default values for MaxIdleConns, MaxOpenConns, ConnMaxLifetime.
This commit is contained in:
iRedMail
2022-01-25 19:58:19 +08:00
committed by GitHub
parent 5048d2480c
commit ff1db4e2a4
3 changed files with 64 additions and 19 deletions

View File

@@ -41,10 +41,13 @@ store := sqlite3.New()
// Initialize custom config
store := sqlite3.New(sqlite3.Config{
Database: "./fiber.sqlite3",
Table: "fiber_storage",
Reset: false,
GCInterval: 10 * time.Second,
Database: "./fiber.sqlite3",
Table: "fiber_storage",
Reset: false,
GCInterval: 10 * time.Second,
MaxOpenConns: 100,
MaxIdleConns: 100,
ConnMaxLifetime: 1 * time.Second,
})
```
@@ -70,15 +73,37 @@ type Config struct {
//
// Optional. Default is 10 * time.Second
GCInterval time.Duration
// //////////////////////////////////
// Adaptor related config options //
// //////////////////////////////////
// MaxIdleConns sets the maximum number of connections in the idle connection pool.
//
// Optional. Default is 100.
MaxIdleConns int
// MaxOpenConns sets the maximum number of open connections to the database.
//
// Optional. Default is 100.
MaxOpenConns int
// ConnMaxLifetime sets the maximum amount of time a connection may be reused.
//
// Optional. Default is 1 second.
ConnMaxLifetime time.Duration
}
```
### Default Config
```go
var ConfigDefault = Config{
Database: "./fiber.sqlite3",
Table: "fiber_storage",
Reset: false,
GCInterval: 10 * time.Second,
Database: "./fiber.sqlite3",
Table: "fiber_storage",
Reset: false,
GCInterval: 10 * time.Second,
MaxOpenConns: 100,
MaxIdleConns: 100,
ConnMaxLifetime: 1 * time.Second,
}
```