You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
478 B
26 lines
478 B
package rdb
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
"zestack.dev/env"
|
|
)
|
|
|
|
var rdb *redis.Client
|
|
|
|
func Init() error {
|
|
rdb = redis.NewClient(&redis.Options{
|
|
Network: env.String("REDIS_NETWORK", "tcp"),
|
|
Addr: fmt.Sprintf("%s:%d", env.String("REDIS_HOST"), env.Int("REDIS_PORT", 6379)),
|
|
DB: env.Int("REDIS_DB", 0),
|
|
Username: env.String("REDIS_USER"),
|
|
Password: env.String("REDIS_AUTH"),
|
|
})
|
|
|
|
return nil
|
|
}
|
|
|
|
func Redis() *redis.Client {
|
|
return rdb
|
|
}
|
|
|