Commit 148961f3 authored by 陈志良's avatar 陈志良

照片墙热门帖子缓存10秒

parent 3363b4d2
......@@ -390,27 +390,37 @@ exports.getThreadById = function(tid, callback) {
// });
// },
// function(cb) {
//获取照片墙最热文章列表
// if (doc.type !== 3) {
// cb(null, null);
// return;
// }
// var conditions = {
// pid: tid,
// type: 3,
// status:1,
// images: {$exists: true, $not: {$size: 0}}
// };
// getAllThreadByFidHelp(conditions, 1, 10, '-praise_count', function(err, threads) {
// if (err) {
// console.error(err);
// cb(err, null);
// } else {
// cb(null, threads);
// }
// });
// },
function(cb) {
// 获取照片墙最热文章列表
if (doc.type !== 3) {
cb(null, null);
return;
}
var conditions = {
pid: tid,
type: 3,
status:1,
images: {$exists: true, $not: {$size: 0}}
};
var key = 'pisns-forum-thread:' + tid + ':subThreads';
redis.get(key,function(err,value){
if (value) {
cb(null, JSON.parse(value));
} else {
getAllThreadByFidHelp(conditions, 1, 10, '-praise_count', function(err, threads) {
if (err) {
console.error(err);
cb(err, null);
} else {
redis.set(key, JSON.stringify(threads));
redis.expire(key, 10);
cb(null, threads);
}
});
}
});
},
function(cb) {
//获取发帖人数
var key = 'pisns-forum-thread:' + tid + ':amount';
......
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