Files
NodeBB/src/posts/cache.js

32 lines
525 B
JavaScript
Raw Normal View History

2017-02-18 02:23:47 -07:00
'use strict';
let cache = null;
exports.getOrCreate = function () {
if (!cache) {
2024-06-10 17:18:41 -04:00
const cacheCreate = require('../cache/lru');
const meta = require('../meta');
cache = cacheCreate({
name: 'post',
maxSize: meta.config.postCacheSize,
sizeCalculation: function (n) { return n.length || 1; },
ttl: 0,
enabled: global.env === 'production',
});
}
return cache;
};
exports.del = function (pid) {
if (cache) {
cache.del(pid);
}
2024-06-10 17:17:46 -04:00
};
exports.reset = function () {
if (cache) {
cache.reset();
}
2024-06-10 17:17:46 -04:00
};