feat: 公众号登录 共享access_token方案 #3
|
|
@ -0,0 +1,23 @@
|
||||||
|
package cache
|
||||||
|
|
||||||
|
import "github.com/go-redis/redis"
|
||||||
|
|
||||||
|
var (
|
||||||
|
redisClient *redis.Client = nil
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewRedis() {
|
||||||
|
addr := "127.0.0.1:6379"
|
||||||
|
redis.NewClient(&redis.Options{})
|
||||||
|
|
||||||
|
redisClient = redis.NewClient(&redis.Options{
|
||||||
|
Addr: addr,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRedis() *redis.Client {
|
||||||
|
if redisClient == nil {
|
||||||
|
NewRedis()
|
||||||
|
}
|
||||||
|
return redisClient
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue