mirror of
https://github.com/gofiber/storage.git
synced 2025-12-24 13:29:30 +08:00
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:
@@ -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,
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user