|
|
|
@ -2,7 +2,6 @@ package common
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/go-redis/redis/v8"
|
|
|
|
|
"log"
|
|
|
|
|
"os"
|
|
|
|
@ -98,12 +97,6 @@ func GetRedisFromConsul(vip *viper.Viper) (red *redis.Client, err error) {
|
|
|
|
|
PoolSize: vip.GetInt("poolSize"),
|
|
|
|
|
MinIdleConns: vip.GetInt("minIdleConn"),
|
|
|
|
|
})
|
|
|
|
|
//集群
|
|
|
|
|
clusterClients := redis.NewClusterClient(
|
|
|
|
|
&redis.ClusterOptions{
|
|
|
|
|
Addrs: []string{"192.168.100.131:6380", "192.168.100.131:6381", "192.168.100.131:6382"},
|
|
|
|
|
})
|
|
|
|
|
fmt.Println(clusterClients)
|
|
|
|
|
return red, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -112,6 +105,11 @@ func SetUserToken(red *redis.Client, key string, val []byte, timeTTL time.Durati
|
|
|
|
|
red.Set(context.Background(), key, val, timeTTL)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 订单Token
|
|
|
|
|
func SetOrderToken(red *redis.Client, key string, val string, timeTTL time.Duration) {
|
|
|
|
|
red.Set(context.Background(), key, val, timeTTL)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取用户登录信息
|
|
|
|
|
func GetUserToken(red *redis.Client, key string) string {
|
|
|
|
|
res, err := red.Get(context.Background(), key).Result()
|
|
|
|
|