feat: #8824, cache refactor (#8851)

* feat: #8824, cache refactor

ability to disable caches
ability to download contents of cache
refactor cache modules to remove duplicated code

* fix: remove duplicate hit/miss tracking

check cacheEnabled in getUncachedKeys
This commit is contained in:
Barış Soner Uşaklı
2020-11-06 23:13:12 -05:00
committed by GitHub
parent bcbc085497
commit f1f9b225b0
23 changed files with 226 additions and 199 deletions

View File

@@ -57,13 +57,12 @@ module.exports = function (Posts) {
const cachedContent = cache.get(pid);
if (postData.pid && cachedContent !== undefined) {
postData.content = cachedContent;
cache.hits += 1;
return postData;
}
cache.misses += 1;
const data = await plugins.fireHook('filter:parse.post', { postData: postData });
data.postData.content = translator.escape(data.postData.content);
if (global.env === 'production' && data.postData.pid) {
if (data.postData.pid) {
cache.set(pid, data.postData.content);
}
return data.postData;