spu分离

parent 494a5de2
......@@ -13,5 +13,14 @@ max_idle = 2000
max_active = 5000
idle_timeout = 20
;新spu redis
[default_redis_spu]
host = 192.168.1.234:6379
password = icDb29mLy2s
max_idle = 2000
max_active = 5000
idle_timeout = 20
;存放redis所有键
[redis_all]
\ No newline at end of file
......@@ -16,6 +16,8 @@ func BuildRedisConfigs() (RedisDatabaseMap map[string]RedisDatabase) {
redisReadMaxActive,_ := Get("default_redis_read.max_active").Int()
redisWriteMaxIdle,_ := Get("default_redis_write.max_idle").Int()
redisWriteMaxActive,_ := Get("default_redis_write.max_active").Int()
redisSpuMaxIdle,_ := Get("default_redis_spu.max_idle").Int()
redisSpuMaxActive,_ := Get("default_redis_spu.max_active").Int()
return map[string]RedisDatabase{
"search_r": {
Host: Get("default_redis_read.host").String(),
......@@ -35,5 +37,11 @@ func BuildRedisConfigs() (RedisDatabaseMap map[string]RedisDatabase) {
MaxIdle: redisWriteMaxIdle,
MaxActive: redisWriteMaxActive,
},
"spu": {
Host: Get("default_redis_spu.host").String(),
Password: Get("default_redis_spu.password").String(),
MaxIdle: redisSpuMaxIdle,
MaxActive: redisSpuMaxActive,
},
}
}
......@@ -32,8 +32,10 @@ type Power struct {
*/
func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan sync.Map) {
redisConn := gredis.Conn("search_r")
redisConnSpu := gredis.Conn("spu")
defer func() {
redisConn.Close()
redisConnSpu.Close()
}()
fast := ctx.Request.FormValue("power[fast]")
//是否展示属性
......@@ -59,7 +61,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//读取包装字段的缓存
if sku.SupplierId == 7 || sku.SupplierId == 13 {
//sku_raw_map哪里写入(成意写的)
packing, _ := redis.String(redisConn.Do("HGET", "sku_raw_map", goodsId))
packing, _ := redis.String(redisConnSpu.Do("HGET", "sku_raw_map", goodsId))
sku.Packing = gjson.Get(packing, "pack").String()
}
sku = ls.GetGoodsImages(sku, spu)
......
......@@ -16,6 +16,6 @@ func (ss *SpuService) getSpuList(skuArr map[string]string) (spuList map[string]s
spuIds = append(spuIds, spuId)
}
//批量获取spu详情
spuList = gredis.Hmget("default_r", "spu", spuIds)
spuList = gredis.Hmget("spu", "spu", spuIds)
return
}
......@@ -34,9 +34,11 @@ type ZiyingService struct {
*/
func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan sync.Map) {
redisConn := gredis.Conn("search_r")
redisConnSpu := gredis.Conn("spu")
defer func() {
//wg.Done();
redisConn.Close()
redisConnSpu.Close()
}()
skuArr := gredis.Hmget("search_r", "Self_SelfGoods", goodsIds) //批量获取商品详情
......@@ -108,7 +110,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
var brandId int64
var brandName string
if spuId != 0 {
spuStr, _ := gredis.String(redisConn.Do("HGET", "spu", spuId))
spuStr, _ := gredis.String(redisConnSpu.Do("HGET", "spu", spuId))
brandId = gjson.Get(spuStr, "brand_id").Int()
brandName, _ = gredis.String(redisConn.Do("HGET", "brand", brandId))
var ly LyService
......
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