Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_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
38ca63d0
authored
Jul 03, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
d5169cd4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
13 deletions
cmd/test1.go
pkg/config/config.go
pkg/gredis/redis.go
service/common_ly_service.go
cmd/test1.go
View file @
38ca63d0
package
main
import
(
"flag"
"fmt"
"os"
"search_server/boot"
"search_server/pkg/gredis"
"search_server/service"
)
func
main
()
{
//MouserService := service.NewMouserServiceImpl()
//MouserGetData(MouserService)
var
path
string
flag
.
StringVar
(
&
path
,
"config"
,
"conf"
,
"配置文件"
)
flag
.
Parse
()
if
err
:=
boot
.
Boot
(
path
);
err
!=
nil
{
panic
(
err
)
}
lock_key
:=
"searchapi_6666"
;
//flag := gredis.Set(lock_key,php2go.Time()+2)
flag
:=
gredis
.
Setnx
(
lock_key
,
2222
)
fmt
.
Println
(
flag
)
os
.
Exit
(
1
)
dd
:=
service
.
OutLink
(
"LM358"
,
"-1"
)
print
(
"niin"
)
print
(
dd
)
...
...
pkg/config/config.go
View file @
38ca63d0
...
...
@@ -11,7 +11,7 @@ var (
func
SetUp
(
path
string
)
(
err
error
)
{
//引入多个文件
Cfg
,
err
=
ini
.
LooseLoad
(
path
+
"/config.ini"
,
path
+
"/search.ini"
)
Cfg
,
err
=
ini
.
LooseLoad
(
path
+
"/config.ini"
,
path
+
"/search.ini"
,
path
+
"/redis_key.ini"
,
path
+
"/rabmq_key.ini"
)
return
}
...
...
pkg/gredis/redis.go
View file @
38ca63d0
...
...
@@ -71,6 +71,24 @@ func Set(key string, data interface{}) error {
return
nil
}
//Redis Setnx(SET if Not eXists) 命令在指定的 key 不存在时,为 key 设置指定的值。
func
Setnx
(
key
string
,
data
interface
{})
error
{
conn
:=
writeConn
.
Get
()
defer
conn
.
Close
()
value
,
err
:=
json
.
Marshal
(
data
)
if
err
!=
nil
{
return
err
}
_
,
err
=
conn
.
Do
(
"SETNX"
,
key
,
value
)
if
err
!=
nil
{
return
err
}
return
nil
}
func
Exists
(
key
string
)
bool
{
conn
:=
readConn
.
Get
()
defer
conn
.
Close
()
...
...
service/common_ly_service.go
View file @
38ca63d0
...
...
@@ -2,9 +2,12 @@ package service
import
(
"fmt"
"github.com/syyongx/php2go"
_
"github.com/tidwall/gjson"
"search_server/model"
"search_server/pkg/gredis"
"search_server/pkg/config"
"strings"
)
//关键词搜索过期时间
...
...
@@ -24,18 +27,26 @@ var supplier_over_time = map[string]int64{
*/
func
getSkuByGoodsSn
(
goods_list
map
[
string
]
*
model
.
LyClearGoodsList
,
supplier_info
*
model
.
SUPPLIER_REDIS_INFO_
)
map
[
string
]
interface
{}{
//originGoods := make(map[string]interface{},0)
//
//for goods_sn, goods_list := range goods_list {
// gredis.HGet("")
//
// ladderPrice := make([]*model.TierItem, 0)
//
// productList[goodsSn] = &LyClearGoodsList
//}
//
//fmt.Println(productList)
//return productList
originGoods
:=
make
(
map
[
string
]
interface
{},
0
)
sku_uique_judge
:=
config
.
Get
(
"redis_all.SKU_UNIQUE_JUDGE"
)
.
String
()
for
goods_sn
,
info
:=
range
goods_list
{
sn_sku
:=
php2go
.
Md5
(
strings
.
ToLower
(
goods_sn
))
sku_id
,
_
:=
gredis
.
HGet
(
sku_uique_judge
,
sn_sku
)
//查询唯一值,反查sku_id
if
sku_id
==
""
{
//为空,先创建sku
//lock_key := "searchapi_"+sn_sku;
//flag := gredis.Setnx(lock_key,php2go.Time()+2)
//if flag { //存在锁
//
//}
}
print
(
info
)
//productList[goodsSn] = &LyClearGoodsList
}
fmt
.
Println
(
originGoods
)
return
originGoods
}
/*
新增或者更新redis
...
...
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