Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
shijian
8 years ago
Commit
51c8ac6cbafabfdc3a5ebdddefde1a5f3a71b639
1 parent
3b2826d8
超时时间
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
utils/getTDK.js
utils/getTDK.js
View file @
51c8ac6
...
...
@@ -6,11 +6,23 @@ module.exports = (type, query, req) => {
query
=
type
===
'url'
?
md5
(
query
)
:
query
;
if
(
redis
&&
_
.
get
(
req
.
app
.
locals
.
pc
,
'ci.tdk'
,
false
))
{
return
redis
.
multi
([
let
arr
=
[];
arr
.
push
(
redis
.
multi
([
[
'exists'
,
`
tdk
:
$
{
type
}
:
$
{
query
}
`
],
[
'hmget'
,
`
tdk
:
$
{
type
}
:
$
{
query
}
`
,
'key'
,
'title'
,
'keywords'
,
'description'
]
]).
execAsync
().
then
(
function
(
res
)
{
return
res
[
1
];
]).
execAsync
());
arr
.
push
(
new
Promise
((
resolve
)
=>
{
setTimeout
(
resolve
,
500
,
[]);
}));
return
Promise
.
race
(
arr
).
then
(
function
(
res
)
{
if
(
res
.
length
)
{
return
res
[
1
];
}
else
{
return
[];
}
});
}
else
{
return
Promise
.
resolve
([]);
...
...
Please
register
or
login
to post a comment