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
a325e553
Commit
a325e553
authored
Aug 27, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formCacheTest
parent
f6dbba5f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
gsb-marketplat/app/base/api/impl/action/template.js
+18
-2
gsb-marketplat/app/base/service/impl/configmag/forminfoSve.js
+1
-0
gsb-marketplat/app/base/utils/redisClient.js
+5
-0
No files found.
gsb-marketplat/app/base/api/impl/action/template.js
View file @
a325e553
...
...
@@ -12,6 +12,7 @@ class Template extends APIBase {
this
.
formsubmitrecordSve
=
system
.
getObject
(
"service.configmag.formsubmitrecordSve"
);
this
.
forminfoSve
=
system
.
getObject
(
"service.configmag.forminfoSve"
);
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
formCache
=
{};
}
/**
* 接口跳转-POST请求
...
...
@@ -55,7 +56,16 @@ class Template extends APIBase {
async
getFormInfoById
(
pobj
,
qobj
,
req
){
var
shaStr
=
"forminfo_"
+
pobj
.
id
;
var
rtn
=
await
this
.
redisClient
.
get
(
shaStr
);
// 先试图从redis读取数据
var
rtn
=
null
;
console
.
log
(
this
.
formCache
,
"+++++++++++++getFormInfoById++++++++++++++++++++++"
);
if
(
this
.
formCache
[
shaStr
]){
rtn
=
this
.
formCache
[
shaStr
];
}
else
{
rtn
=
await
this
.
redisClient
.
get
(
shaStr
);
// 先试图从redis读取数据
if
(
rtn
){
this
.
formCache
[
shaStr
]
=
rtn
;
}
}
//---- 从redis中读取到数据
if
(
rtn
)
{
var
rtnObj
=
JSON
.
parse
(
rtn
);
...
...
@@ -64,9 +74,15 @@ class Template extends APIBase {
let
result
=
await
this
.
forminfoSve
.
findOne
({
id
:
pobj
.
id
},[]);
// 将数据保存到redis中
await
this
.
redisClient
.
set
(
shaStr
,
JSON
.
stringify
(
result
));
this
.
formCache
[
shaStr
]
=
JSON
.
stringify
(
result
);
return
system
.
getResult
(
result
);
}
}
//删除表单缓存
async
delTemplateFormCache
(
key
){
if
(
key
&&
this
.
formCache
[
key
]){
delete
this
.
formCache
[
key
];
}
}
}
module
.
exports
=
Template
;
gsb-marketplat/app/base/service/impl/configmag/forminfoSve.js
View file @
a325e553
...
...
@@ -130,6 +130,7 @@ class ForminfoService extends ServiceBase {
let
result
=
await
this
.
updateByWhere
(
upData
,{
id
:
pobj
.
id
})
var
shaStr
=
"forminfo_"
+
pobj
.
id
;
await
this
.
redisClient
.
delete
(
shaStr
);
await
this
.
redisClient
.
publish
(
"delTemplateFormCache"
,
shaStr
);
return
system
.
getResult
(
result
);
}
...
...
gsb-marketplat/app/base/utils/redisClient.js
View file @
a325e553
...
...
@@ -63,8 +63,13 @@ class RedisClient {
var
tempLinkSve
=
system
.
getObject
(
"service.template.templatelinkSve"
);
await
tempLinkSve
.
clearTemplateLinkInfoCache
(
message
);
}
if
(
channel
==
"delTemplateFormCache"
&&
message
){
var
template
=
system
.
getObject
(
"api.action.template"
);
await
template
.
delTemplateFormCache
(
message
);
}
});
this
.
subscribe
(
"delTemplateCache"
,
null
);
this
.
subscribe
(
"delTemplateFormCache"
,
null
);
}
async
subscribe
(
channel
,
chatserver
)
{
...
...
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