Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
7d58992a
Commit
7d58992a
authored
Jan 06, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
a42f6ffe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
bigdata/app/base/db/cache.base.js
+4
-3
bigdata/app/base/utils/businessManager/authUtils.js
+3
-2
No files found.
bigdata/app/base/db/cache.base.js
View file @
7d58992a
...
...
@@ -20,7 +20,7 @@ class CacheBase {
async
cache
(
inputkey
,
val
,
ex
,
...
items
)
{
const
cachekey
=
this
.
prefix
+
inputkey
;
var
cacheValue
=
await
this
.
redisClient
.
get
(
cachekey
);
if
(
!
cacheValue
||
cacheValue
==
"undefined"
||
cacheValue
==
"null"
||
this
.
isdebug
)
{
if
(
!
cacheValue
||
cacheValue
==
"undefined"
||
cacheValue
==
"null"
||
this
.
isdebug
)
{
var
objvalstr
=
await
this
.
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
);
if
(
!
objvalstr
)
{
return
null
;
...
...
@@ -34,11 +34,12 @@ class CacheBase {
this
.
redisClient
.
sadd
(
this
.
cacheCacheKeyPrefix
,
[
cachekey
+
"|"
+
this
.
desc
]);
return
JSON
.
parse
(
objvalstr
);
}
else
{
this
.
redisClient
.
setWithEx
(
cachekey
,
cacheValue
,
ex
);
return
JSON
.
parse
(
cacheValue
);
}
}
async
invalidate
(
inputkey
){
const
cachekey
=
this
.
prefix
+
inputkey
;
async
invalidate
(
inputkey
)
{
const
cachekey
=
this
.
prefix
+
inputkey
;
this
.
redisClient
.
delete
(
cachekey
);
return
0
;
}
...
...
bigdata/app/base/utils/businessManager/authUtils.js
View file @
7d58992a
...
...
@@ -3,6 +3,7 @@ const uuidv4 = require('uuid/v4');
class
AuthUtils
{
constructor
()
{
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
exTime
=
5
*
3600
;
//缓存过期时间,5小时
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
@@ -16,11 +17,11 @@ class AuthUtils {
*/
async
getTokenInfo
(
appkey
,
secret
)
{
var
rtnKey
=
this
.
getUUID
();
var
cacheAccessKey
=
await
this
.
cacheManager
[
"ApiAccessKeyClientCache"
].
cache
(
appkey
,
rtnKey
,
3600
);
var
cacheAccessKey
=
await
this
.
cacheManager
[
"ApiAccessKeyClientCache"
].
cache
(
appkey
,
rtnKey
,
this
.
exTime
);
if
(
cacheAccessKey
)
{
rtnKey
=
cacheAccessKey
.
accessKey
;
}
//获取之前的token值
var
appData
=
await
this
.
cacheManager
[
"ApiAccessKeyCache"
].
cache
(
rtnKey
,
secret
,
3600
,
appkey
);
var
appData
=
await
this
.
cacheManager
[
"ApiAccessKeyCache"
].
cache
(
rtnKey
,
secret
,
this
.
exTime
,
appkey
);
if
(
!
appData
)
{
return
system
.
getResultFail
(
system
.
getAppInfoFail
,
"key或secret错误."
);
}
...
...
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