Commit c248f4ac by mushishixian

整合redis

parent 26d8bc65
Showing with 8 additions and 4 deletions
......@@ -2,6 +2,7 @@ package service
import (
"fmt"
"github.com/gomodule/redigo/redis"
_ "github.com/gomodule/redigo/redis"
"github.com/tidwall/gjson"
"gopkg.in/olivere/elastic.v5"
......@@ -9,6 +10,7 @@ import (
"search_server/pkg/common"
"search_server/pkg/config"
"search_server/pkg/es"
"search_server/pkg/gredis"
_ "search_server/pkg/gredis"
"strconv"
"strings"
......@@ -46,8 +48,9 @@ func SearchAttr(attrOrigin, encap string) (goodsName string, err error) {
numberR, _ := regexp.Compile(common.PureNumberRegular)
pureNumber := numberR.FindString(encap)
//再去找对应属性
//attrName, _ := redis.String(gredis.HGet("sku_map2", pureNumber))
attrName := ""
redisConn := gredis.Conn("default_redis_read")
defer redisConn.Close()
attrName, _ := redis.String(redisConn.Do("HGET", "sku_map2", pureNumber))
if attrName != "" {
attrValue := attrName + "€" + pureNumber
attrsSlice = append(attrsSlice, attrValue)
......@@ -200,8 +203,9 @@ func getAttrValueByAttr(attr string) (attrValue string) {
}
} else {
//再去找没有单位的对应属性
//attrName, _ = redis.String(gredis.HGet("sku_map2", attr))
attrName := ""
redisConn := gredis.Conn("default_redis_read")
defer redisConn.Close()
attrName, _ := redis.String(redisConn.Do("HGET", "sku_map2", pureNumber))
if attrName != "" {
attrValue = attrName + "€" + attr
} else {
......
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