forked from ebhomengo/niki
1
0
Fork 0
niki/adapter/redis/adapter.go

33 lines
552 B
Go

package redis
import (
"fmt"
"github.com/redis/go-redis/v9"
)
type Config struct {
Host string `koanf:"host"`
Port int `koanf:"port"`
Password string `koanf:"password"`
DB int `koanf:"db"`
}
type Adapter struct {
client *redis.Client
}
func New(config Config) Adapter {
rdb := redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%s:%d", config.Host, config.Port),
Password: config.Password,
DB: config.DB,
})
return Adapter{client: rdb}
}
func (a Adapter) Client() *redis.Client {
return a.client
}