22 lines
392 B
Go
22 lines
392 B
Go
|
package redis
|
||
|
|
||
|
import "github.com/go-redis/redis"
|
||
|
|
||
|
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,
|
||
|
})
|
||
|
if err := client.Ping().Err(); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return &Redis{
|
||
|
Client: client,
|
||
|
}, nil
|
||
|
}
|