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.

32 lines
529 B

1 month ago
package redis
import (
redis "github.com/alauda/go-redis-client"
_ "github.com/petermattis/goid"
)
type Client struct {
*redis.Client
addr string
prefix string
}
func NewClient(addr, prefix string) (*Client, error) {
opts := redis.Options{
Type: redis.ClientNormal,
Hosts: []string{addr},
KeyPrefix: prefix,
}
client := redis.NewClient(opts)
_, err := client.Ping().Result()
if err != nil {
return nil, err
}
c := &Client{
Client: client,
addr: addr,
prefix: prefix,
}
return c, nil
}