Compare commits
2 Commits
02d8a509ff
...
136c4634c8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
136c4634c8 | ||
|
|
987ac2fe4a |
@ -6,7 +6,7 @@ type Redis struct {
|
|||||||
DB int `mapstructure:"db"`
|
DB int `mapstructure:"db"`
|
||||||
Username string `mapstructure:"username"`
|
Username string `mapstructure:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `mapstructure:"password"`
|
||||||
SslMode string `mapstructure:"ssl-mode"`
|
SSL bool `mapstructure:"ssl"`
|
||||||
Debug bool `mapstructure:"debug"`
|
Debug bool `mapstructure:"debug"`
|
||||||
MaxIdleConnectionsInSecond int `mapstructure:"max-idle-connections-in-second"`
|
MaxIdleConnectionsInSecond int `mapstructure:"max-idle-connections-in-second"`
|
||||||
MaxOpenConnectionsInSecond int `mapstructure:"max-open-connections-in-second"`
|
MaxOpenConnectionsInSecond int `mapstructure:"max-open-connections-in-second"`
|
||||||
|
|||||||
2
env/debug.yaml
vendored
2
env/debug.yaml
vendored
@ -36,7 +36,7 @@ redis:
|
|||||||
username: red-d046l42dbo4c73ea9iag
|
username: red-d046l42dbo4c73ea9iag
|
||||||
password: 7cZvu08JKuO9MPNxBb97tZCVNj0ZGNp2
|
password: 7cZvu08JKuO9MPNxBb97tZCVNj0ZGNp2
|
||||||
db: 5
|
db: 5
|
||||||
ssl: false
|
ssl: true
|
||||||
max-idle-connections-in-second: 600
|
max-idle-connections-in-second: 600
|
||||||
max-open-connections-in-second: 600
|
max-open-connections-in-second: 600
|
||||||
connection-max-life-time-in-second: 600
|
connection-max-life-time-in-second: 600
|
||||||
|
|||||||
2
env/staging.yaml
vendored
2
env/staging.yaml
vendored
@ -36,7 +36,7 @@ redis:
|
|||||||
username: red-d04c8k49c44c739ga8dg
|
username: red-d04c8k49c44c739ga8dg
|
||||||
password: ItPzniHv94yr8vY4HTrhCfKoibqBh61T
|
password: ItPzniHv94yr8vY4HTrhCfKoibqBh61T
|
||||||
db: 5
|
db: 5
|
||||||
ssl: false
|
ssl: true
|
||||||
max-idle-connections-in-second: 600
|
max-idle-connections-in-second: 600
|
||||||
max-open-connections-in-second: 600
|
max-open-connections-in-second: 600
|
||||||
connection-max-life-time-in-second: 600
|
connection-max-life-time-in-second: 600
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package redisaccessor
|
package redisaccessor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"legalgo-BE-go/config"
|
"legalgo-BE-go/config"
|
||||||
|
|
||||||
@ -16,11 +17,19 @@ func Get() *redis.Client {
|
|||||||
func New(cfg *config.Config) *redis.Client {
|
func New(cfg *config.Config) *redis.Client {
|
||||||
addr := fmt.Sprintf("%s:%s", cfg.Redis.Host, cfg.Redis.Port)
|
addr := fmt.Sprintf("%s:%s", cfg.Redis.Host, cfg.Redis.Port)
|
||||||
|
|
||||||
redisClient = redis.NewClient(&redis.Options{
|
options := &redis.Options{
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
Password: cfg.Redis.Password,
|
Password: cfg.Redis.Password,
|
||||||
DB: cfg.Redis.DB,
|
DB: cfg.Redis.DB,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if cfg.Redis.Username != "" {
|
||||||
|
options.Username = cfg.Redis.Username
|
||||||
|
}
|
||||||
|
if cfg.Redis.SSL {
|
||||||
|
options.TLSConfig = &tls.Config{}
|
||||||
|
}
|
||||||
|
|
||||||
|
redisClient = redis.NewClient(options)
|
||||||
return redisClient
|
return redisClient
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user