master
shenzhuan 2 years ago
parent ab1a5ce676
commit 77909564b9

@ -2,7 +2,6 @@ package common
import ( import (
"context" "context"
"fmt"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
"log" "log"
"os" "os"
@ -98,12 +97,6 @@ func GetRedisFromConsul(vip *viper.Viper) (red *redis.Client, err error) {
PoolSize: vip.GetInt("poolSize"), PoolSize: vip.GetInt("poolSize"),
MinIdleConns: vip.GetInt("minIdleConn"), 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 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) 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 { func GetUserToken(red *redis.Client, key string) string {
res, err := red.Get(context.Background(), key).Result() res, err := red.Get(context.Background(), key).Result()

Loading…
Cancel
Save