From b0f630aaec44c8b272b5dcea5066240be20e0f38 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 31 Aug 2016 21:39:02 +0300 Subject: [PATCH] always use string as cache key --- src/posts/edit.js | 4 ++-- src/posts/parse.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/posts/edit.js b/src/posts/edit.js index 333901c1fa..5bb76ec019 100644 --- a/src/posts/edit.js +++ b/src/posts/edit.js @@ -68,8 +68,8 @@ module.exports = function(Posts) { plugins.fireHook('action:post.edit', _.clone(postData)); - cache.del(postData.pid); - pubsub.publish('post:edit', postData.pid); + cache.del(String(postData.pid)); + pubsub.publish('post:edit', String(postData.pid)); Posts.parsePost(postData, next); }, diff --git a/src/posts/parse.js b/src/posts/parse.js index 19e6430681..88fa5f8c22 100644 --- a/src/posts/parse.js +++ b/src/posts/parse.js @@ -15,8 +15,8 @@ module.exports = function(Posts) { Posts.parsePost = function(postData, callback) { postData.content = postData.content || ''; - if (postData.pid && cache.has(postData.pid)) { - postData.content = cache.get(postData.pid); + if (postData.pid && cache.has(String(postData.pid))) { + postData.content = cache.get(String(postData.pid)); return callback(null, postData); } @@ -33,7 +33,7 @@ module.exports = function(Posts) { data.postData.content = translator.escape(data.postData.content); if (global.env === 'production' && data.postData.pid) { - cache.set(data.postData.pid, data.postData.content); + cache.set(String(data.postData.pid), data.postData.content); } callback(null, data.postData);