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]
|
||||
name: Memory Test
|
||||
name: Memory
|
||||
jobs:
|
||||
Build:
|
||||
Tests:
|
||||
strategy:
|
||||
matrix:
|
||||
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]
|
||||
name: MongoDB test
|
||||
name: MongoDB
|
||||
jobs:
|
||||
mongodb-tests:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mongo:
|
||||
|
4
.github/workflows/test-mysql.yml
vendored
4
.github/workflows/test-mysql.yml
vendored
@@ -1,7 +1,7 @@
|
||||
on: [push, pull_request]
|
||||
name: MySQL test
|
||||
name: MySQL
|
||||
jobs:
|
||||
mysql-tests:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mysql:
|
||||
|
4
.github/workflows/test-redis.yml
vendored
4
.github/workflows/test-redis.yml
vendored
@@ -1,7 +1,7 @@
|
||||
on: [push, pull_request]
|
||||
name: Redis test
|
||||
name: Redis
|
||||
jobs:
|
||||
redis-tests:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
redis:
|
||||
|
4
.github/workflows/test-sqlite3.yml
vendored
4
.github/workflows/test-sqlite3.yml
vendored
@@ -1,7 +1,7 @@
|
||||
on: [push, pull_request]
|
||||
name: SQLite3 test
|
||||
name: SQLite3
|
||||
jobs:
|
||||
Build:
|
||||
Tests:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.14.x, 1.15.x]
|
||||
|
@@ -34,16 +34,21 @@ store := memcache.New(memcache.Config{
|
||||
```go
|
||||
type Config struct {
|
||||
// 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"
|
||||
Servers string
|
||||
|
||||
// Clear any existing keys in existing Table
|
||||
//
|
||||
// Optional. Default is false
|
||||
Clear bool
|
||||
}
|
||||
```
|
||||
|
||||
### Default Config
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
Servers: "localhost:11211",
|
||||
Servers: "127.0.0.1:11211",
|
||||
}
|
||||
```
|
||||
|
@@ -26,57 +26,68 @@ store := mongodb.New()
|
||||
|
||||
// Initialize custom config
|
||||
store := mongodb.New(mongodb.Config{
|
||||
URI: "mongodb://127.0.0.1:27017",
|
||||
Host: "127.0.0.1",
|
||||
Port: 27017,
|
||||
Database: "fiber",
|
||||
Collection: "fiber",
|
||||
Collection: "fiber_storage",
|
||||
Clear: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
})
|
||||
```
|
||||
|
||||
### Config
|
||||
```go
|
||||
type Config struct {
|
||||
//https://docs.mongodb.com/manual/reference/connection-string/
|
||||
URI string
|
||||
// Host name where the DB is hosted
|
||||
//
|
||||
// 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
|
||||
|
||||
// https://pkg.go.dev/go.mongodb.org/mongo-driver@v1.4.2/mongo/options#ClientOptions
|
||||
AppName string
|
||||
Auth options.Credential
|
||||
AutoEncryptionOptions *options.AutoEncryptionOptions
|
||||
ConnectTimeout time.Duration
|
||||
Compressors []string
|
||||
Dialer options.ContextDialer
|
||||
Direct bool
|
||||
DisableOCSPEndpointCheck bool
|
||||
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
|
||||
// Clear any existing keys in existing Table
|
||||
//
|
||||
// Optional. Default is false
|
||||
Clear bool
|
||||
|
||||
// Time before deleting expired keys
|
||||
//
|
||||
// Optional. Default is 10 * time.Second
|
||||
GCInterval time.Duration
|
||||
}
|
||||
```
|
||||
|
||||
### Default Config
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
URI: "mongodb://127.0.0.1:27017",
|
||||
Host: "127.0.0.1",
|
||||
Port: 27017,
|
||||
Database: "fiber",
|
||||
Collection: "fiber",
|
||||
Collection: "fiber_storage",
|
||||
Clear: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
}
|
||||
```
|
||||
|
@@ -26,10 +26,11 @@ store := mysql.New()
|
||||
|
||||
// Initialize custom config
|
||||
store := mysql.New(mysql.Config{
|
||||
Server: "127.0.0.1:3306",
|
||||
Host: "127.0.0.1",
|
||||
Port: 3306,
|
||||
Database: "fiber",
|
||||
Table: "fiber",
|
||||
Drop: false,
|
||||
Table: "fiber_storage",
|
||||
Clear: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
})
|
||||
```
|
||||
@@ -37,10 +38,15 @@ store := mysql.New(mysql.Config{
|
||||
### Config
|
||||
```go
|
||||
type Config struct {
|
||||
// Server address in <host>:<port> format
|
||||
// Host name where the DB is hosted
|
||||
//
|
||||
// Optional. Default is "127.0.0.1:3306"
|
||||
Server string
|
||||
// Optional. Default is "127.0.0.1"
|
||||
Host string
|
||||
|
||||
// Port where the DB is listening on
|
||||
//
|
||||
// Optional. Default is 3306
|
||||
Port int
|
||||
|
||||
// Server username
|
||||
//
|
||||
@@ -59,13 +65,13 @@ type Config struct {
|
||||
|
||||
// Table name
|
||||
//
|
||||
// Optional. Default is "fiber"
|
||||
// Optional. Default is "fiber_storage"
|
||||
Table string
|
||||
|
||||
// Drop any existing table with the same Table name
|
||||
// Clear any existing keys in existing Table
|
||||
//
|
||||
// Optional. Default is false
|
||||
Drop bool
|
||||
Clear bool
|
||||
|
||||
// Time before deleting expired keys
|
||||
//
|
||||
@@ -77,10 +83,11 @@ type Config struct {
|
||||
### Default Config
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
Server: "127.0.0.1:3306",
|
||||
Host: "127.0.0.1",
|
||||
Port: 3306,
|
||||
Database: "fiber",
|
||||
Table: "fiber",
|
||||
Drop: false,
|
||||
Table: "fiber_storage",
|
||||
Clear: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
}
|
||||
```
|
||||
|
@@ -26,12 +26,12 @@ store := postgres.New()
|
||||
|
||||
// Initialize custom config
|
||||
store := postgres.New(postgres.Config{
|
||||
GCInterval: 10 * time.Second,
|
||||
Host: "127.0.0.1",
|
||||
Port: 5432,
|
||||
Database: "fiber",
|
||||
TableName: "fiber",
|
||||
DropTable: false,
|
||||
Table: "fiber_storage",
|
||||
Clear: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
})
|
||||
```
|
||||
|
||||
@@ -39,56 +39,56 @@ store := postgres.New(postgres.Config{
|
||||
```go
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
// Time before deleting expired keys
|
||||
//
|
||||
// Default is 10 * time.Second
|
||||
GCInterval time.Duration
|
||||
|
||||
// DB host
|
||||
// Host name where the DB is hosted
|
||||
//
|
||||
// Optional. Default is "127.0.0.1"
|
||||
Host string
|
||||
|
||||
// DB port
|
||||
// Port where the DB is listening on
|
||||
//
|
||||
// Optional. Default is "5432"
|
||||
Port int64
|
||||
// Optional. Default is 5432
|
||||
Port int
|
||||
|
||||
// DB user name
|
||||
// Server username
|
||||
//
|
||||
// Optional. Default is ""
|
||||
Username string
|
||||
|
||||
// DB user password
|
||||
// Server password
|
||||
//
|
||||
// Optional. Default is ""
|
||||
Password string
|
||||
|
||||
// DB name
|
||||
// Database name
|
||||
//
|
||||
// Optional. Default is "fiber"
|
||||
Database string
|
||||
|
||||
// DB table name
|
||||
// Table name
|
||||
//
|
||||
// Optional. Default is "fiber"
|
||||
TableName string
|
||||
// Optional. Default is "fiber_storage"
|
||||
Table string
|
||||
|
||||
// Drop any existing table with the same name
|
||||
// Clear any existing keys in existing Table
|
||||
//
|
||||
// Optional. Default is false
|
||||
DropTable bool
|
||||
Clear bool
|
||||
|
||||
// Time before deleting expired keys
|
||||
//
|
||||
// Optional. Default is 10 * time.Second
|
||||
GCInterval time.Duration
|
||||
}
|
||||
```
|
||||
|
||||
### Default Config
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
GCInterval: 10 * time.Second,
|
||||
Host: "127.0.0.1",
|
||||
Port: 5432,
|
||||
Database: "fiber",
|
||||
TableName: "fiber",
|
||||
DropTable: false,
|
||||
Table: "fiber_storage",
|
||||
Clear: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
}
|
||||
```
|
||||
|
119
redis/README.md
119
redis/README.md
@@ -26,103 +26,47 @@ store := redis.New()
|
||||
|
||||
// Initialize custom 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
|
||||
```go
|
||||
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.
|
||||
// Default is tcp.
|
||||
Network string
|
||||
|
||||
// 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.
|
||||
// Server username
|
||||
//
|
||||
// Optional. Default is ""
|
||||
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),
|
||||
// or the User Password when connecting to a Redis 6.0 instance, or greater,
|
||||
// that is using the Redis ACL system.
|
||||
|
||||
// Server password
|
||||
//
|
||||
// Optional. Default is ""
|
||||
Password string
|
||||
|
||||
// Database to be selected after connecting to the server.
|
||||
DB int
|
||||
//
|
||||
// Optional. Default is 0
|
||||
Database int
|
||||
|
||||
// Maximum number of retries before giving up.
|
||||
// Default is 3 retries.
|
||||
MaxRetries int
|
||||
|
||||
// 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
|
||||
// Clear any existing keys in existing Collection
|
||||
//
|
||||
// Optional. Default is false
|
||||
Clear bool
|
||||
}
|
||||
|
||||
```
|
||||
@@ -130,6 +74,11 @@ type Config struct {
|
||||
### Default Config
|
||||
```go
|
||||
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
|
||||
store := sqlite3.New(sqlite3.Config{
|
||||
GCInterval: 10 * time.Second,
|
||||
Database: "./fiber.sqlite3",
|
||||
TableName: "fiber",
|
||||
DropTable: false,
|
||||
Table: "fiber_storage",
|
||||
Clear: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
})
|
||||
```
|
||||
|
||||
### Config
|
||||
```go
|
||||
type Config struct {
|
||||
// Time before deleting expired keys
|
||||
// Database name
|
||||
//
|
||||
// Default is 10 * time.Second
|
||||
GCInterval time.Duration
|
||||
|
||||
// DB file path
|
||||
//
|
||||
// Default is "./fiber.sqlite3"
|
||||
// Optional. Default is "fiber"
|
||||
Database string
|
||||
|
||||
// DB table name
|
||||
// Table name
|
||||
//
|
||||
// Default is "fiber"
|
||||
TableName string
|
||||
// Optional. Default is "fiber_storage"
|
||||
Table string
|
||||
|
||||
// When set to true, this will Drop any existing table with the same name
|
||||
DropTable bool
|
||||
// Clear any existing keys in existing Table
|
||||
//
|
||||
// Optional. Default is false
|
||||
Clear bool
|
||||
|
||||
// Time before deleting expired keys
|
||||
//
|
||||
// Optional. Default is 10 * time.Second
|
||||
GCInterval time.Duration
|
||||
}
|
||||
```
|
||||
|
||||
### Default Config
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
GCInterval: 10 * time.Second,
|
||||
Database: "./fiber.sqlite3",
|
||||
TableName: "fiber",
|
||||
DropTable: false,
|
||||
Table: "fiber_storage",
|
||||
Clear: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user