Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
29
pkg/redisv2/connection.go
Normal file
29
pkg/redisv2/connection.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package redisv2
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"fiskerinc.com/modules/utils/envtool"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
// connection vars
|
||||
var ()
|
||||
|
||||
// Actual connection to the redis
|
||||
func NewConnection() (redisClient *redis.Client) {
|
||||
host := envtool.GetEnv("REDIS_HOST", "localhost")
|
||||
port := envtool.GetEnv("REDIS_PORT", "6379")
|
||||
username := envtool.GetEnv("REDIS_USERNAME", "default")
|
||||
password := envtool.GetEnv("REDIS_PASSWORD", "REPLACE_ME")
|
||||
addr := fmt.Sprintf("%v:%v", host, port)
|
||||
rdb := redis.NewClient(&redis.Options{
|
||||
Addr: addr,
|
||||
Username: username,
|
||||
Password: password,
|
||||
MaxActiveConns: envtool.GetEnvInt("REDIS_MAXACTIVECONN", 10),
|
||||
PoolSize: envtool.GetEnvInt("REDIS_POOLSIZE", 10),
|
||||
})
|
||||
|
||||
return rdb
|
||||
}
|
||||
Reference in New Issue
Block a user