mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
feat: analytics:maxCache setting in ACP
I removed a TODO from core. Watch your head as flying pigs are abound
This commit is contained in:
@@ -10,6 +10,7 @@ const LRU = require('lru-cache');
|
||||
const db = require('./database');
|
||||
const utils = require('./utils');
|
||||
const plugins = require('./plugins');
|
||||
const meta = require('./meta');
|
||||
|
||||
const Analytics = module.exports;
|
||||
|
||||
@@ -21,21 +22,19 @@ let pageViewsGuest = 0;
|
||||
let pageViewsBot = 0;
|
||||
let uniqueIPCount = 0;
|
||||
let uniquevisitors = 0;
|
||||
let ipCache;
|
||||
|
||||
/**
|
||||
* TODO: allow the cache's max value to be configurable. On high-traffic installs,
|
||||
* the cache could be exhausted continuously if there are more than 500 concurrently
|
||||
* active users
|
||||
*/
|
||||
var ipCache = new LRU({
|
||||
max: 500,
|
||||
length: function () { return 1; },
|
||||
maxAge: 0,
|
||||
});
|
||||
Analytics.init = async function () {
|
||||
ipCache = new LRU({
|
||||
max: parseInt(meta.config['analytics:maxCache'], 10) || 500,
|
||||
length: function () { return 1; },
|
||||
maxAge: 0,
|
||||
});
|
||||
|
||||
new cronJob('*/10 * * * * *', function () {
|
||||
Analytics.writeData();
|
||||
}, null, true);
|
||||
new cronJob('*/10 * * * * *', function () {
|
||||
Analytics.writeData();
|
||||
}, null, true);
|
||||
};
|
||||
|
||||
Analytics.increment = function (keys, callback) {
|
||||
keys = Array.isArray(keys) ? keys : [keys];
|
||||
|
||||
Reference in New Issue
Block a user