mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 08:37:10 +08:00
update readme
This commit is contained in:
4
.github/workflows/test-memory.yml
vendored
4
.github/workflows/test-memory.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
name: Memory Test
|
name: Memory
|
||||||
jobs:
|
jobs:
|
||||||
Build:
|
Tests:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [1.14.x, 1.15.x]
|
go-version: [1.14.x, 1.15.x]
|
||||||
|
4
.github/workflows/test-mongodb.yml
vendored
4
.github/workflows/test-mongodb.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
name: MongoDB test
|
name: MongoDB
|
||||||
jobs:
|
jobs:
|
||||||
mongodb-tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
mongo:
|
mongo:
|
||||||
|
4
.github/workflows/test-mysql.yml
vendored
4
.github/workflows/test-mysql.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
name: MySQL test
|
name: MySQL
|
||||||
jobs:
|
jobs:
|
||||||
mysql-tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
|
4
.github/workflows/test-redis.yml
vendored
4
.github/workflows/test-redis.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
name: Redis test
|
name: Redis
|
||||||
jobs:
|
jobs:
|
||||||
redis-tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
redis:
|
redis:
|
||||||
|
4
.github/workflows/test-sqlite3.yml
vendored
4
.github/workflows/test-sqlite3.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
name: SQLite3 test
|
name: SQLite3
|
||||||
jobs:
|
jobs:
|
||||||
Build:
|
Tests:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [1.14.x, 1.15.x]
|
go-version: [1.14.x, 1.15.x]
|
||||||
|
@@ -34,16 +34,21 @@ store := memcache.New(memcache.Config{
|
|||||||
```go
|
```go
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Server list divided by ,
|
// Server list divided by ,
|
||||||
// i.e. "127.0.0.1:11211, 127.0.0.1:11212"
|
// i.e. server1:11211, server2:11212
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1:11211"
|
// Optional. Default is "127.0.0.1:11211"
|
||||||
Servers string
|
Servers string
|
||||||
|
|
||||||
|
// Clear any existing keys in existing Table
|
||||||
|
//
|
||||||
|
// Optional. Default is false
|
||||||
|
Clear bool
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
Servers: "localhost:11211",
|
Servers: "127.0.0.1:11211",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -26,57 +26,68 @@ store := mongodb.New()
|
|||||||
|
|
||||||
// Initialize custom config
|
// Initialize custom config
|
||||||
store := mongodb.New(mongodb.Config{
|
store := mongodb.New(mongodb.Config{
|
||||||
URI: "mongodb://127.0.0.1:27017",
|
Host: "127.0.0.1",
|
||||||
|
Port: 27017,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
Collection: "fiber",
|
Collection: "fiber_storage",
|
||||||
|
Clear: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Config
|
### Config
|
||||||
```go
|
```go
|
||||||
type Config struct {
|
type Config struct {
|
||||||
//https://docs.mongodb.com/manual/reference/connection-string/
|
// Host name where the DB is hosted
|
||||||
URI string
|
//
|
||||||
Database string
|
// Optional. Default is "127.0.0.1"
|
||||||
|
Host string
|
||||||
|
|
||||||
|
// Port where the DB is listening on
|
||||||
|
//
|
||||||
|
// Optional. Default is 27017
|
||||||
|
Port int
|
||||||
|
|
||||||
|
// Server username
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
Username string
|
||||||
|
|
||||||
|
// Server password
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
Password string
|
||||||
|
|
||||||
|
// Database name
|
||||||
|
//
|
||||||
|
// Optional. Default is "fiber"
|
||||||
|
Database string
|
||||||
|
|
||||||
|
// Collection name
|
||||||
|
//
|
||||||
|
// Optional. Default is "fiber_storage"
|
||||||
Collection string
|
Collection string
|
||||||
|
|
||||||
// https://pkg.go.dev/go.mongodb.org/mongo-driver@v1.4.2/mongo/options#ClientOptions
|
// Clear any existing keys in existing Table
|
||||||
AppName string
|
//
|
||||||
Auth options.Credential
|
// Optional. Default is false
|
||||||
AutoEncryptionOptions *options.AutoEncryptionOptions
|
Clear bool
|
||||||
ConnectTimeout time.Duration
|
|
||||||
Compressors []string
|
// Time before deleting expired keys
|
||||||
Dialer options.ContextDialer
|
//
|
||||||
Direct bool
|
// Optional. Default is 10 * time.Second
|
||||||
DisableOCSPEndpointCheck bool
|
GCInterval time.Duration
|
||||||
HeartbeatInterval time.Duration
|
|
||||||
Hosts []string
|
|
||||||
LocalThreshold time.Duration
|
|
||||||
MaxConnIdleTime time.Duration
|
|
||||||
MaxPoolSize uint64
|
|
||||||
MinPoolSize uint64
|
|
||||||
PoolMonitor *event.PoolMonitor
|
|
||||||
Monitor *event.CommandMonitor
|
|
||||||
ReadConcern *readconcern.ReadConcern
|
|
||||||
ReadPreference *readpref.ReadPref
|
|
||||||
Registry *bsoncodec.Registry
|
|
||||||
ReplicaSet string
|
|
||||||
RetryReads bool
|
|
||||||
RetryWrites bool
|
|
||||||
ServerSelectionTimeout time.Duration
|
|
||||||
SocketTimeout time.Duration
|
|
||||||
TLSConfig *tls.Config
|
|
||||||
WriteConcern *writeconcern.WriteConcern
|
|
||||||
ZlibLevel int
|
|
||||||
ZstdLevel int
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
URI: "mongodb://127.0.0.1:27017",
|
Host: "127.0.0.1",
|
||||||
|
Port: 27017,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
Collection: "fiber",
|
Collection: "fiber_storage",
|
||||||
|
Clear: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -26,10 +26,11 @@ store := mysql.New()
|
|||||||
|
|
||||||
// Initialize custom config
|
// Initialize custom config
|
||||||
store := mysql.New(mysql.Config{
|
store := mysql.New(mysql.Config{
|
||||||
Server: "127.0.0.1:3306",
|
Host: "127.0.0.1",
|
||||||
|
Port: 3306,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
Table: "fiber",
|
Table: "fiber_storage",
|
||||||
Drop: false,
|
Clear: false,
|
||||||
GCInterval: 10 * time.Second,
|
GCInterval: 10 * time.Second,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -37,10 +38,15 @@ store := mysql.New(mysql.Config{
|
|||||||
### Config
|
### Config
|
||||||
```go
|
```go
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Server address in <host>:<port> format
|
// Host name where the DB is hosted
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1:3306"
|
// Optional. Default is "127.0.0.1"
|
||||||
Server string
|
Host string
|
||||||
|
|
||||||
|
// Port where the DB is listening on
|
||||||
|
//
|
||||||
|
// Optional. Default is 3306
|
||||||
|
Port int
|
||||||
|
|
||||||
// Server username
|
// Server username
|
||||||
//
|
//
|
||||||
@@ -59,13 +65,13 @@ type Config struct {
|
|||||||
|
|
||||||
// Table name
|
// Table name
|
||||||
//
|
//
|
||||||
// Optional. Default is "fiber"
|
// Optional. Default is "fiber_storage"
|
||||||
Table string
|
Table string
|
||||||
|
|
||||||
// Drop any existing table with the same Table name
|
// Clear any existing keys in existing Table
|
||||||
//
|
//
|
||||||
// Optional. Default is false
|
// Optional. Default is false
|
||||||
Drop bool
|
Clear bool
|
||||||
|
|
||||||
// Time before deleting expired keys
|
// Time before deleting expired keys
|
||||||
//
|
//
|
||||||
@@ -77,10 +83,11 @@ type Config struct {
|
|||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
Server: "127.0.0.1:3306",
|
Host: "127.0.0.1",
|
||||||
|
Port: 3306,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
Table: "fiber",
|
Table: "fiber_storage",
|
||||||
Drop: false,
|
Clear: false,
|
||||||
GCInterval: 10 * time.Second,
|
GCInterval: 10 * time.Second,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -26,12 +26,12 @@ store := postgres.New()
|
|||||||
|
|
||||||
// Initialize custom config
|
// Initialize custom config
|
||||||
store := postgres.New(postgres.Config{
|
store := postgres.New(postgres.Config{
|
||||||
GCInterval: 10 * time.Second,
|
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 5432,
|
Port: 5432,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
TableName: "fiber",
|
Table: "fiber_storage",
|
||||||
DropTable: false,
|
Clear: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -39,56 +39,56 @@ store := postgres.New(postgres.Config{
|
|||||||
```go
|
```go
|
||||||
// Config defines the config for storage.
|
// Config defines the config for storage.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Time before deleting expired keys
|
// Host name where the DB is hosted
|
||||||
//
|
|
||||||
// Default is 10 * time.Second
|
|
||||||
GCInterval time.Duration
|
|
||||||
|
|
||||||
// DB host
|
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1"
|
// Optional. Default is "127.0.0.1"
|
||||||
Host string
|
Host string
|
||||||
|
|
||||||
// DB port
|
// Port where the DB is listening on
|
||||||
//
|
//
|
||||||
// Optional. Default is "5432"
|
// Optional. Default is 5432
|
||||||
Port int64
|
Port int
|
||||||
|
|
||||||
// DB user name
|
// Server username
|
||||||
//
|
//
|
||||||
// Optional. Default is ""
|
// Optional. Default is ""
|
||||||
Username string
|
Username string
|
||||||
|
|
||||||
// DB user password
|
// Server password
|
||||||
//
|
//
|
||||||
// Optional. Default is ""
|
// Optional. Default is ""
|
||||||
Password string
|
Password string
|
||||||
|
|
||||||
// DB name
|
// Database name
|
||||||
//
|
//
|
||||||
// Optional. Default is "fiber"
|
// Optional. Default is "fiber"
|
||||||
Database string
|
Database string
|
||||||
|
|
||||||
// DB table name
|
// Table name
|
||||||
//
|
//
|
||||||
// Optional. Default is "fiber"
|
// Optional. Default is "fiber_storage"
|
||||||
TableName string
|
Table string
|
||||||
|
|
||||||
// Drop any existing table with the same name
|
// Clear any existing keys in existing Table
|
||||||
//
|
//
|
||||||
// Optional. Default is false
|
// Optional. Default is false
|
||||||
DropTable bool
|
Clear bool
|
||||||
|
|
||||||
|
// Time before deleting expired keys
|
||||||
|
//
|
||||||
|
// Optional. Default is 10 * time.Second
|
||||||
|
GCInterval time.Duration
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
GCInterval: 10 * time.Second,
|
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 5432,
|
Port: 5432,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
TableName: "fiber",
|
Table: "fiber_storage",
|
||||||
DropTable: false,
|
Clear: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
119
redis/README.md
119
redis/README.md
@@ -26,103 +26,47 @@ store := redis.New()
|
|||||||
|
|
||||||
// Initialize custom config
|
// Initialize custom config
|
||||||
store := redis.New(redis.Config{
|
store := redis.New(redis.Config{
|
||||||
Addr: "127.0.0.1:6379",
|
Host: "127.0.0.1",
|
||||||
|
Port: 6379,
|
||||||
|
Username: "",
|
||||||
|
Password: "",
|
||||||
|
Database: 0,
|
||||||
|
Clear: false,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Config
|
### Config
|
||||||
```go
|
```go
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Custom options
|
// Host name where the DB is hosted
|
||||||
|
//
|
||||||
|
// Optional. Default is "127.0.0.1"
|
||||||
|
Host string
|
||||||
|
|
||||||
// https://pkg.go.dev/github.com/go-redis/redis/v8#Options
|
// Port where the DB is listening on
|
||||||
|
//
|
||||||
|
// Optional. Default is 3306
|
||||||
|
Port int
|
||||||
|
|
||||||
// The network type, either tcp or unix.
|
// Server username
|
||||||
// Default is tcp.
|
//
|
||||||
Network string
|
// Optional. Default is ""
|
||||||
|
|
||||||
// host:port address.
|
|
||||||
Addr string
|
|
||||||
|
|
||||||
// Dialer creates new network connection and has priority over
|
|
||||||
// Network and Addr options.
|
|
||||||
Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
|
|
||||||
|
|
||||||
// Hook that is called when new connection is established.
|
|
||||||
OnConnect func(ctx context.Context, cn *redis.Conn) error
|
|
||||||
|
|
||||||
// Use the specified Username to authenticate the current connection
|
|
||||||
// with one of the connections defined in the ACL list when connecting
|
|
||||||
// to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
|
|
||||||
Username string
|
Username string
|
||||||
// Optional password. Must match the password specified in the
|
|
||||||
// requirepass server configuration option (if connecting to a Redis 5.0 instance, or lower),
|
// Server password
|
||||||
// or the User Password when connecting to a Redis 6.0 instance, or greater,
|
//
|
||||||
// that is using the Redis ACL system.
|
// Optional. Default is ""
|
||||||
Password string
|
Password string
|
||||||
|
|
||||||
// Database to be selected after connecting to the server.
|
// Database to be selected after connecting to the server.
|
||||||
DB int
|
//
|
||||||
|
// Optional. Default is 0
|
||||||
|
Database int
|
||||||
|
|
||||||
// Maximum number of retries before giving up.
|
// Clear any existing keys in existing Collection
|
||||||
// Default is 3 retries.
|
//
|
||||||
MaxRetries int
|
// Optional. Default is false
|
||||||
|
Clear bool
|
||||||
// Minimum backoff between each retry.
|
|
||||||
// Default is 8 milliseconds; -1 disables backoff.
|
|
||||||
MinRetryBackoff time.Duration
|
|
||||||
|
|
||||||
// Maximum backoff between each retry.
|
|
||||||
// Default is 512 milliseconds; -1 disables backoff.
|
|
||||||
MaxRetryBackoff time.Duration
|
|
||||||
|
|
||||||
// Dial timeout for establishing new connections.
|
|
||||||
// Default is 5 seconds.
|
|
||||||
DialTimeout time.Duration
|
|
||||||
|
|
||||||
// Timeout for socket reads. If reached, commands will fail
|
|
||||||
// with a timeout instead of blocking. Use value -1 for no timeout and 0 for default.
|
|
||||||
// Default is 3 seconds.
|
|
||||||
ReadTimeout time.Duration
|
|
||||||
|
|
||||||
// Timeout for socket writes. If reached, commands will fail
|
|
||||||
// with a timeout instead of blocking.
|
|
||||||
// Default is ReadTimeout.
|
|
||||||
WriteTimeout time.Duration
|
|
||||||
|
|
||||||
// Maximum number of socket connections.
|
|
||||||
// Default is 10 connections per every CPU as reported by runtime.NumCPU.
|
|
||||||
PoolSize int
|
|
||||||
|
|
||||||
// Minimum number of idle connections which is useful when establishing
|
|
||||||
// new connection is slow.
|
|
||||||
MinIdleConns int
|
|
||||||
|
|
||||||
// Connection age at which client retires (closes) the connection.
|
|
||||||
// Default is to not close aged connections.
|
|
||||||
MaxConnAge time.Duration
|
|
||||||
|
|
||||||
// Amount of time client waits for connection if all connections
|
|
||||||
// are busy before returning an error.
|
|
||||||
// Default is ReadTimeout + 1 second.
|
|
||||||
PoolTimeout time.Duration
|
|
||||||
|
|
||||||
// Amount of time after which client closes idle connections.
|
|
||||||
// Should be less than server's timeout.
|
|
||||||
// Default is 5 minutes. -1 disables idle timeout check.
|
|
||||||
IdleTimeout time.Duration
|
|
||||||
|
|
||||||
// Frequency of idle checks made by idle connections reaper.
|
|
||||||
// Default is 1 minute. -1 disables idle connections reaper,
|
|
||||||
// but idle connections are still discarded by the client
|
|
||||||
// if IdleTimeout is set.
|
|
||||||
IdleCheckFrequency time.Duration
|
|
||||||
|
|
||||||
// TLS Config to use. When set TLS will be negotiated.
|
|
||||||
TLSConfig *tls.Config
|
|
||||||
|
|
||||||
// Limiter interface used to implemented circuit breaker or rate limiter.
|
|
||||||
Limiter redis.Limiter
|
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -130,6 +74,11 @@ type Config struct {
|
|||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
Addr: "127.0.0.1:6379",
|
Host: "127.0.0.1",
|
||||||
|
Port: 6379,
|
||||||
|
Username: "",
|
||||||
|
Password: "",
|
||||||
|
Database: 0,
|
||||||
|
Clear: false,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -26,42 +26,44 @@ store := sqlite3.New()
|
|||||||
|
|
||||||
// Initialize custom config
|
// Initialize custom config
|
||||||
store := sqlite3.New(sqlite3.Config{
|
store := sqlite3.New(sqlite3.Config{
|
||||||
GCInterval: 10 * time.Second,
|
Database: "./fiber.sqlite3",
|
||||||
Database: "./fiber.sqlite3",
|
Table: "fiber_storage",
|
||||||
TableName: "fiber",
|
Clear: false,
|
||||||
DropTable: false,
|
GCInterval: 10 * time.Second,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Config
|
### Config
|
||||||
```go
|
```go
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Time before deleting expired keys
|
// Database name
|
||||||
//
|
//
|
||||||
// Default is 10 * time.Second
|
// Optional. Default is "fiber"
|
||||||
GCInterval time.Duration
|
|
||||||
|
|
||||||
// DB file path
|
|
||||||
//
|
|
||||||
// Default is "./fiber.sqlite3"
|
|
||||||
Database string
|
Database string
|
||||||
|
|
||||||
// DB table name
|
// Table name
|
||||||
//
|
//
|
||||||
// Default is "fiber"
|
// Optional. Default is "fiber_storage"
|
||||||
TableName string
|
Table string
|
||||||
|
|
||||||
// When set to true, this will Drop any existing table with the same name
|
// Clear any existing keys in existing Table
|
||||||
DropTable bool
|
//
|
||||||
|
// Optional. Default is false
|
||||||
|
Clear bool
|
||||||
|
|
||||||
|
// Time before deleting expired keys
|
||||||
|
//
|
||||||
|
// Optional. Default is 10 * time.Second
|
||||||
|
GCInterval time.Duration
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
GCInterval: 10 * time.Second,
|
Database: "./fiber.sqlite3",
|
||||||
Database: "./fiber.sqlite3",
|
Table: "fiber_storage",
|
||||||
TableName: "fiber",
|
Clear: false,
|
||||||
DropTable: false,
|
GCInterval: 10 * time.Second,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user