22 lines
376 B
Go
22 lines
376 B
Go
|
package initialize
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"github.com/go-redis/redis/v8"
|
||
|
)
|
||
|
|
||
|
func Redis(ctx context.Context, cfg Config) (*redis.Client, error) {
|
||
|
rdb := redis.NewClient(&redis.Options{
|
||
|
Addr: cfg.RedisHost,
|
||
|
Password: cfg.RedisPassword,
|
||
|
DB: cfg.RedisDB,
|
||
|
})
|
||
|
|
||
|
status := rdb.Ping(ctx)
|
||
|
if err := status.Err(); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return rdb, nil
|
||
|
}
|