Commit 7a894190 by 庄冰

appinfoCache

parent 3df92378
......@@ -5,6 +5,7 @@ class SignService{
constructor() {
this.centerAppUrl = settings.centerAppUrl();
this.restClient = system.getObject("util.restClient");
this.redisClient = system.getObject("util.redisClient");
}
async restPostUrl(pobj, url) {
try {
......@@ -20,6 +21,22 @@ class SignService{
}
}
async getAppInfoByAppKey(appkey){
try {
var shaStr = "getAppInfoByAppKey_"+appkey;
var cacheRes = await this.redisClient.get(shaStr);
if (cacheRes) {
return JSON.parse(cacheRes);
}
let url = this.centerAppUrl + 'payment/paymentApi/getAppInfoByAppKey';
let appInfoRt = await this.restPostUrl({ appKey: appkey }, url);
if(appInfoRt && appInfoRt.status==0){
//保存缓存
await this.redisClient.setWithEx(shaStr, JSON.stringify(appInfoRt), 3600);
}
return appInfoRt;
} catch (error) {
var errres = system.getResultFail("获取应用信息失败!");
}
let url = this.centerAppUrl + 'payment/paymentApi/getAppInfoByAppKey';
let appInfoRt = await this.restPostUrl({ appKey: appkey }, url);
return appInfoRt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment