Commit 75308da1 by mushishixian

redis多个

parent 7c4539de
...@@ -13,15 +13,7 @@ max_active = 100 ...@@ -13,15 +13,7 @@ max_active = 100
idle_timeout = 20 idle_timeout = 20
[api_redis_read] [api_redis]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
[api_redis_write]
host = 192.168.1.235:6379 host = 192.168.1.235:6379
password = icDb29mLy2s password = icDb29mLy2s
max_idle = 50 max_idle = 50
......
...@@ -25,5 +25,11 @@ func BuildRedisConfgs() (RedisDatabaseMap map[string]RedisDatabase) { ...@@ -25,5 +25,11 @@ func BuildRedisConfgs() (RedisDatabaseMap map[string]RedisDatabase) {
MaxIdle: Get("default_redis_read.max_idle").String(), MaxIdle: Get("default_redis_read.max_idle").String(),
MaxActive: Get("default_redis_read.max_active").String(), MaxActive: Get("default_redis_read.max_active").String(),
}, },
"api_redis": {
Host: Get("api_redis.host").String(),
Password: Get("api_redis.password").String(),
MaxIdle: Get("api_redis.max_idle").String(),
MaxActive: Get("api_redis.max_active").String(),
},
} }
} }
...@@ -40,8 +40,17 @@ func GetGoodsInfoByApi(goodsIdsStr string) (goodsList []model.ApiGoods, err erro ...@@ -40,8 +40,17 @@ func GetGoodsInfoByApi(goodsIdsStr string) (goodsList []model.ApiGoods, err erro
//isMap:是否以字典形式返回值,默认是数组 //isMap:是否以字典形式返回值,默认是数组
func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiGoods, goodsListMap map[string]model.ApiGoods, err error) { func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiGoods, goodsListMap map[string]model.ApiGoods, err error) {
goodsIdList := strings.Split(goodsIdsStr, ",")
if len(goodsIdList) == 0 {
return
}
//req.Debug = true //req.Debug = true
goodsServerUrl := config.Get("goods.api_url").String() var goodsServerUrl string
if len(goodsIdList[0]) > 7 {
goodsServerUrl = config.Get("goods.api_url").String()
}else{
goodsServerUrl = config.Get("goods.sz_api_url").String()
}
resp, err := req.Post(goodsServerUrl+"/synchronization", params) resp, err := req.Post(goodsServerUrl+"/synchronization", params)
if err != nil { if err != nil {
return return
...@@ -50,7 +59,6 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG ...@@ -50,7 +59,6 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
//先判断返回的data是不是字典,不是字典代表可能是返回字符串了 //先判断返回的data是不是字典,不是字典代表可能是返回字符串了
if gjson.Get(resp.String(), "data").IsObject() { if gjson.Get(resp.String(), "data").IsObject() {
//排序操作 //排序操作
goodsIdList := strings.Split(goodsIdsStr, ",")
for _, goodsId := range goodsIdList { for _, goodsId := range goodsIdList {
for _, data := range gjson.Get(resp.String(), "data").Map() { for _, data := range gjson.Get(resp.String(), "data").Map() {
if goodsId == data.Get("goods_id").String() { if goodsId == data.Get("goods_id").String() {
...@@ -193,7 +201,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG ...@@ -193,7 +201,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
func CheckIsNewCustomer(userId int) (isNewCustomer, isMember bool) { func CheckIsNewCustomer(userId int) (isNewCustomer, isMember bool) {
//判断新客价 //判断新客价
if userId != 0 { if userId != 0 {
redisConn := gredis.Conn("search_r") redisConn := gredis.Conn("api_redis")
defer redisConn.Close() defer redisConn.Close()
userInfoStr, err := redis.String(redisConn.Do("HGET", "api_user", userId)) userInfoStr, err := redis.String(redisConn.Do("HGET", "api_user", userId))
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment