Commit caade030 authored by 陈志良's avatar 陈志良

1.修改子帖子缓存2秒

2.增加用户经验查询2分钟缓存
parent 9c9a29b3
......@@ -2444,7 +2444,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
handleThreadList(req, results, ent_code, function(result){
console.log("查询用户对帖子点赞耗时:"+Math.abs(new Date() - handleThreadListBegin));
redis.set(key, JSON.stringify(result));
redis.expire(key, 5);
redis.expire(key, 2);
res.json(_.assign(result, returnCode.SUCCESS));
});
});
......
......@@ -127,14 +127,25 @@ function loadLevelFromAPI(ent_code,open_id,callback){
if(!ent_code || !open_id){
return callback && callback(null,null);
}
var url = API_ADDRESS + '/v1.0/internal/member/exp/byopenid?openId='+open_id+'&entCode='+ent_code;
request.get({
url: url,
json: {}
}, function(e, r, body) {
if (e) {
console.log(e)
var key = 'pisns-forum-thread:' +ent_code+':'+ open_id + ':exp';
redis.get(key,function(err,value){
if (value) {
return callback && callback(null,Number(value) || null);
} else {
var url = API_ADDRESS + '/v1.0/internal/member/exp/byopenid?openId='+open_id+'&entCode='+ent_code;
request.get({
url: url,
json: {}
}, function(e, r, body) {
if (e) {
console.log(e)
}
if(body && body.data){
redis.set(key, body.data);
redis.expire(key,2 * 60 );
}
return callback && callback(null,(body && body.data) || null);
});
}
return callback && callback(null,(body && body.data) || null);
});
};
\ No newline at end of file
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