Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
32cb67b8
authored
Jul 17, 2023
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
spu分离
parent
494a5de2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
3 deletions
conf/dev/redis.ini
pkg/config/redis.go
service/service_ly.go
service/service_spu.go
service/service_zy.go
service/service_zy_common.go
conf/dev/redis.ini
View file @
32cb67b8
...
@@ -13,5 +13,14 @@ max_idle = 2000
...
@@ -13,5 +13,14 @@ max_idle = 2000
max_active
=
5000
max_active
=
5000
idle_timeout
=
20
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所有键
[redis_all]
[redis_all]
\ No newline at end of file
pkg/config/redis.go
View file @
32cb67b8
...
@@ -16,6 +16,8 @@ func BuildRedisConfigs() (RedisDatabaseMap map[string]RedisDatabase) {
...
@@ -16,6 +16,8 @@ func BuildRedisConfigs() (RedisDatabaseMap map[string]RedisDatabase) {
redisReadMaxActive
,
_
:=
Get
(
"default_redis_read.max_active"
)
.
Int
()
redisReadMaxActive
,
_
:=
Get
(
"default_redis_read.max_active"
)
.
Int
()
redisWriteMaxIdle
,
_
:=
Get
(
"default_redis_write.max_idle"
)
.
Int
()
redisWriteMaxIdle
,
_
:=
Get
(
"default_redis_write.max_idle"
)
.
Int
()
redisWriteMaxActive
,
_
:=
Get
(
"default_redis_write.max_active"
)
.
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
{
return
map
[
string
]
RedisDatabase
{
"search_r"
:
{
"search_r"
:
{
Host
:
Get
(
"default_redis_read.host"
)
.
String
(),
Host
:
Get
(
"default_redis_read.host"
)
.
String
(),
...
@@ -35,5 +37,11 @@ func BuildRedisConfigs() (RedisDatabaseMap map[string]RedisDatabase) {
...
@@ -35,5 +37,11 @@ func BuildRedisConfigs() (RedisDatabaseMap map[string]RedisDatabase) {
MaxIdle
:
redisWriteMaxIdle
,
MaxIdle
:
redisWriteMaxIdle
,
MaxActive
:
redisWriteMaxActive
,
MaxActive
:
redisWriteMaxActive
,
},
},
"spu"
:
{
Host
:
Get
(
"default_redis_spu.host"
)
.
String
(),
Password
:
Get
(
"default_redis_spu.password"
)
.
String
(),
MaxIdle
:
redisSpuMaxIdle
,
MaxActive
:
redisSpuMaxActive
,
},
}
}
}
}
service/service_ly.go
View file @
32cb67b8
...
@@ -32,8 +32,10 @@ type Power struct {
...
@@ -32,8 +32,10 @@ type Power struct {
*/
*/
func
(
ls
*
LyService
)
LyGoodsDetail
(
ctx
*
gin
.
Context
,
goodsIds
[]
string
,
ch
chan
sync
.
Map
)
{
func
(
ls
*
LyService
)
LyGoodsDetail
(
ctx
*
gin
.
Context
,
goodsIds
[]
string
,
ch
chan
sync
.
Map
)
{
redisConn
:=
gredis
.
Conn
(
"search_r"
)
redisConn
:=
gredis
.
Conn
(
"search_r"
)
redisConnSpu
:=
gredis
.
Conn
(
"spu"
)
defer
func
()
{
defer
func
()
{
redisConn
.
Close
()
redisConn
.
Close
()
redisConnSpu
.
Close
()
}()
}()
fast
:=
ctx
.
Request
.
FormValue
(
"power[fast]"
)
fast
:=
ctx
.
Request
.
FormValue
(
"power[fast]"
)
//是否展示属性
//是否展示属性
...
@@ -59,7 +61,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
...
@@ -59,7 +61,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//读取包装字段的缓存
//读取包装字段的缓存
if
sku
.
SupplierId
==
7
||
sku
.
SupplierId
==
13
{
if
sku
.
SupplierId
==
7
||
sku
.
SupplierId
==
13
{
//sku_raw_map哪里写入(成意写的)
//sku_raw_map哪里写入(成意写的)
packing
,
_
:=
redis
.
String
(
redisConn
.
Do
(
"HGET"
,
"sku_raw_map"
,
goodsId
))
packing
,
_
:=
redis
.
String
(
redisConn
Spu
.
Do
(
"HGET"
,
"sku_raw_map"
,
goodsId
))
sku
.
Packing
=
gjson
.
Get
(
packing
,
"pack"
)
.
String
()
sku
.
Packing
=
gjson
.
Get
(
packing
,
"pack"
)
.
String
()
}
}
sku
=
ls
.
GetGoodsImages
(
sku
,
spu
)
sku
=
ls
.
GetGoodsImages
(
sku
,
spu
)
...
...
service/service_spu.go
View file @
32cb67b8
...
@@ -16,6 +16,6 @@ func (ss *SpuService) getSpuList(skuArr map[string]string) (spuList map[string]s
...
@@ -16,6 +16,6 @@ func (ss *SpuService) getSpuList(skuArr map[string]string) (spuList map[string]s
spuIds
=
append
(
spuIds
,
spuId
)
spuIds
=
append
(
spuIds
,
spuId
)
}
}
//批量获取spu详情
//批量获取spu详情
spuList
=
gredis
.
Hmget
(
"
default_r
"
,
"spu"
,
spuIds
)
spuList
=
gredis
.
Hmget
(
"
spu
"
,
"spu"
,
spuIds
)
return
return
}
}
service/service_zy.go
View file @
32cb67b8
...
@@ -34,9 +34,11 @@ type ZiyingService struct {
...
@@ -34,9 +34,11 @@ type ZiyingService struct {
*/
*/
func
(
qs
*
ZiyingService
)
ZyGoodsDetail
(
ctx
*
gin
.
Context
,
goodsIds
[]
string
,
ch
chan
sync
.
Map
)
{
func
(
qs
*
ZiyingService
)
ZyGoodsDetail
(
ctx
*
gin
.
Context
,
goodsIds
[]
string
,
ch
chan
sync
.
Map
)
{
redisConn
:=
gredis
.
Conn
(
"search_r"
)
redisConn
:=
gredis
.
Conn
(
"search_r"
)
redisConnSpu
:=
gredis
.
Conn
(
"spu"
)
defer
func
()
{
defer
func
()
{
//wg.Done();
//wg.Done();
redisConn
.
Close
()
redisConn
.
Close
()
redisConnSpu
.
Close
()
}()
}()
skuArr
:=
gredis
.
Hmget
(
"search_r"
,
"Self_SelfGoods"
,
goodsIds
)
//批量获取商品详情
skuArr
:=
gredis
.
Hmget
(
"search_r"
,
"Self_SelfGoods"
,
goodsIds
)
//批量获取商品详情
...
@@ -108,7 +110,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
...
@@ -108,7 +110,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
var
brandId
int64
var
brandId
int64
var
brandName
string
var
brandName
string
if
spuId
!=
0
{
if
spuId
!=
0
{
spuStr
,
_
:=
gredis
.
String
(
redisConn
.
Do
(
"HGET"
,
"spu"
,
spuId
))
spuStr
,
_
:=
gredis
.
String
(
redisConn
Spu
.
Do
(
"HGET"
,
"spu"
,
spuId
))
brandId
=
gjson
.
Get
(
spuStr
,
"brand_id"
)
.
Int
()
brandId
=
gjson
.
Get
(
spuStr
,
"brand_id"
)
.
Int
()
brandName
,
_
=
gredis
.
String
(
redisConn
.
Do
(
"HGET"
,
"brand"
,
brandId
))
brandName
,
_
=
gredis
.
String
(
redisConn
.
Do
(
"HGET"
,
"brand"
,
brandId
))
var
ly
LyService
var
ly
LyService
...
...
service/service_zy_common.go
View file @
32cb67b8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment