Commit c248f4ac by mushishixian

整合redis

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