well-goknown/redis/redis.go
2023-05-01 18:41:28 -04:00

37 lines
548 B
Go

package redis
import (
"context"
"github.com/redis/go-redis/v9"
)
const (
NostrKeyspace = iota
LndKeyspace = iota
)
type Redis struct {
Client *redis.Client
}
var (
NostrRedisConn *Redis
LndRedisConn *Redis
)
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
}