24 lines
388 B
Go
24 lines
388 B
Go
package cache
|
|
|
|
import (
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
type RedisCache struct {
|
|
rawClient *redis.Client
|
|
}
|
|
|
|
func NewRedisClient(addr string, dbNo int, user, pass string) (*RedisCache, error) {
|
|
opt := &redis.Options{
|
|
Addr: addr,
|
|
DB: dbNo,
|
|
Username: user,
|
|
Password: pass,
|
|
}
|
|
client := redis.NewClient(opt)
|
|
c := &RedisCache{
|
|
rawClient: client,
|
|
}
|
|
return c, nil
|
|
}
|