mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 08:37:10 +08:00
Update README and examples
This commit is contained in:
@@ -17,7 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *redis.Client
|
||||
func (s *Storage) Conn() redis.UniversalClient
|
||||
```
|
||||
### Installation
|
||||
Redis is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||
@@ -46,21 +46,21 @@ store := redis.New(redis.Config{
|
||||
Port: 6379,
|
||||
Username: "",
|
||||
Password: "",
|
||||
URL: "",
|
||||
Database: 0,
|
||||
Reset: false,
|
||||
TLSConfig: nil,
|
||||
PoolSize: 10 * runtime.GOMAXPROCS(0),
|
||||
})
|
||||
|
||||
// Initialize Redis Sentinel Server Client
|
||||
// Initialize Redis Failover Client
|
||||
store := redis.New(redis.Config{
|
||||
EnableFailover: true,
|
||||
MasterName: "master-name",
|
||||
SentinelHosts: []string{":6379", ":6380", ":6381"},
|
||||
ClientName: "",
|
||||
SentinelUsername: "",
|
||||
SentinelPassword: "",
|
||||
Addrs: []string{":6379"},
|
||||
})
|
||||
|
||||
// Initialize Redis Cluster Client
|
||||
store := redis.New(redis.Config{
|
||||
Addrs: []string{":6379", ":6380"},
|
||||
})
|
||||
|
||||
// or just the url with all information
|
||||
@@ -98,12 +98,37 @@ type Config struct {
|
||||
// Optional. Default is 0
|
||||
Database int
|
||||
|
||||
// URL the standard format redis url to parse all other options. If this is set all other config options, Host, Port, Username, Password, Database have no effect.
|
||||
// URL standard format Redis URL. If this is set all other config options, Host, Port, Username, Password, Database have no effect.
|
||||
//
|
||||
// Example: redis://<user>:<pass>@localhost:6379/<db>
|
||||
// Optional. Default is ""
|
||||
URL string
|
||||
|
||||
// Either a single address or a seed list of host:port addresses, this enables FailoverClient and ClusterClient
|
||||
//
|
||||
// Optional. Default is []string{}
|
||||
Addrs []string
|
||||
|
||||
// MasterName is the sentinel master's name
|
||||
//
|
||||
// Optional. Default is ""
|
||||
MasterName string
|
||||
|
||||
// ClientName will execute the `CLIENT SETNAME ClientName` command for each conn.
|
||||
//
|
||||
// Optional. Default is ""
|
||||
ClientName string
|
||||
|
||||
// SentinelUsername
|
||||
//
|
||||
// Optional. Default is ""
|
||||
SentinelUsername string
|
||||
|
||||
// SentinelPassword
|
||||
//
|
||||
// Optional. Default is ""
|
||||
SentinelPassword string
|
||||
|
||||
// Reset clears any existing keys in existing Collection
|
||||
//
|
||||
// Optional. Default is false
|
||||
@@ -118,33 +143,7 @@ type Config struct {
|
||||
//
|
||||
// Optional. Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
|
||||
PoolSize int
|
||||
|
||||
// EnableFailover to use redis FailoverClient with Sentinel instead of the standard redis Client
|
||||
//
|
||||
// Optional. Default is false
|
||||
EnableFailover bool
|
||||
|
||||
// MasterName is the sentinel master's name
|
||||
//
|
||||
// Optional. Default is ""
|
||||
MasterName string
|
||||
|
||||
// SentinelHosts where the Redis Sentinel is hosted
|
||||
//
|
||||
// Optional. Default is []string{}
|
||||
SentinelHosts []string
|
||||
|
||||
// SentinelUsername
|
||||
//
|
||||
// Optional. Default is ""
|
||||
SentinelUsername string
|
||||
|
||||
// SentinelPassword
|
||||
//
|
||||
// Optional. Default is ""
|
||||
SentinelPassword string
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Default Config
|
||||
@@ -159,9 +158,8 @@ var ConfigDefault = Config{
|
||||
Reset: false,
|
||||
TLSConfig: nil,
|
||||
PoolSize: 10 * runtime.GOMAXPROCS(0),
|
||||
EnableFailover: false,
|
||||
Addrs: []string{},
|
||||
MasterName: "",
|
||||
SentinelHosts: []string{},
|
||||
ClientName: "",
|
||||
SentinelUsername: "",
|
||||
SentinelPassword: "",
|
||||
|
Reference in New Issue
Block a user