Commit 7cfc3603 authored by 陈家荣's avatar 陈家荣

更新经验缓存

parent 13117654
......@@ -135,9 +135,11 @@ function loadLevelFromAPI(ent_code,open_id,callback){
return callback && callback(null,null);
}
var key = 'pisns-forum-thread:' +ent_code+':'+ open_id + ':exp';
redis.get(key,function(err,value){
if (value) {
return callback && callback(null,value || null);
var result = JSON.parse(value);
return callback && callback(null,result || null);
} else {
var url = API_ADDRESS + '/v1.0/internal/member/exp/byopenid?openId='+open_id+'&entCode='+ent_code;
request.get({
......@@ -147,8 +149,8 @@ function loadLevelFromAPI(ent_code,open_id,callback){
if (e) {
console.log(e)
}
if(body && body.data ){
redis.set(key, body.data);
if(body && body.data){
redis.set(key, JSON.stringify(body.data));
redis.expire(key,2 * 60 );
}
return callback && callback(null,(body && body.data) || null);
......
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