From bbc42a937ef4b793ff77db45a0f06a6b91c1a6bd Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 26 Nov 2015 23:34:55 -0500 Subject: [PATCH] fixed LRU cache problem --- src/posts/parse.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/posts/parse.js b/src/posts/parse.js index 4d18f9dd7f..4317f024b3 100644 --- a/src/posts/parse.js +++ b/src/posts/parse.js @@ -9,9 +9,8 @@ module.exports = function(Posts) { Posts.parsePost = function(postData, callback) { postData.content = postData.content || ''; - var cachedContent = cache.get(postData.pid); - if (cachedContent) { - postData.content = cachedContent; + if (postData.pid && cache.has(postData.pid)) { + postData.content = cache.get(postData.pid); return callback(null, postData); } @@ -38,4 +37,4 @@ module.exports = function(Posts) { plugins.fireHook('filter:parse.signature', {userData: userData, uid: uid}, callback); }; -}; \ No newline at end of file +};