well-goknown/redis/redis.go
2023-02-04 21:07:26 -05:00

32 lines
481 B
Go

package redis
import (
"context"
"github.com/redis/go-redis/v9"
)
const (
NostrDb = iota
LndDb = iota
)
type Redis struct {
Client *redis.Client
}
func New(address string, password string, database int) (*Redis, error) {
client := redis.NewClient(&redis.Options{
Addr: address,
Password: password,
DB: database,
})
ctx := context.TODO()
if err := client.Ping(ctx).Err(); err != nil {
return nil, err
}
return &Redis{
Client: client,
}, nil
}