Commit 74d9e376 by linboxuan

add cache.base buildCache function

parent 9ad21e81
......@@ -37,6 +37,21 @@ class CacheBase {
return JSON.parse(cacheValue);
}
}
async buildCache(inputkey, val, ex, ...items) {
const cachekey = this.prefix + inputkey;
var objval = await this.buildCacheVal(cachekey, inputkey, val, ex, ...items);
if (!objval || (objval.status && objval.status != 0)) {
return objval;
}
if (ex) {
await this.redisClient.setWithEx(cachekey, JSON.stringify(objval), ex);
} else {
await this.redisClient.set(cachekey, JSON.stringify(objval));
}
//缓存当前应用所有的缓存key及其描述
this.redisClient.sadd(this.cacheCacheKeyPrefix, [cachekey + "|" + this.desc]);
return objval;
}
async getCache(inputkey, ex) {
const cachekey = this.prefix + inputkey;
var cacheValue = await this.redisClient.get(cachekey);
......
......@@ -354,7 +354,9 @@ class OpPlatformUtils {
// return system.getResultFail(system.reDoLoginFail, "请勿重复登录", { userpin: result.data.userpin || "" });
// }
// }
var result = await cacheManager["AppUserPinByLoginVcodeCache"].cache(inputkey, pobj, system.exTime);
// var result = await cacheManager["AppUserPinByLoginVcodeCache"].cache(inputkey, pobj, system.exTime);
// 2020 0805 lin 修改 cache 改为buildCache。buildCache为新增的方法。与cache的区别是 不去get获取 直接走buildCacheVal
var result = await cacheManager["AppUserPinByLoginVcodeCache"].buildCache(inputkey, pobj, system.exTime);
if (result && result.status == 0 && pobj.actionBody.reqType != "reg") {
var userpinKey = this.getUserPinKey(pobj.actionBody.userpin);
this.redisClient.setWithEx(userpinKey, JSON.stringify(result), system.exTime);
......
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