mirror of
https://github.com/keven1024/015.git
synced 2026-05-27 15:39:36 +00:00
23 lines
362 B
Go
23 lines
362 B
Go
package utils
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
var rdb *redis.Client = InitRedis()
|
|
var ctx = context.Background()
|
|
|
|
func InitRedis() *redis.Client {
|
|
opt, err := redis.ParseURL(GetEnv("REDIS_URL"))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return redis.NewClient(opt)
|
|
}
|
|
|
|
func GetRedisClient() (*redis.Client, context.Context) {
|
|
return rdb, ctx
|
|
}
|