removed cache options

This commit is contained in:
Daniel Sommer 2022-03-24 23:35:51 +01:00
parent 72edb1a159
commit c5b5844233
2 changed files with 3 additions and 43 deletions

View file

@ -1,17 +1,13 @@
{
"server": {
"listen": "0.0.0.0",
"port": 3001
"port": 3000
},
"requests": {
"timeout": 5000
},
"cache": {
"active": true,
"lifetime": 0
},
"systemd": [
"docker"
"jack-capture"
],
"log": {
"level": "debug",
@ -28,7 +24,7 @@
},
"blinky": {
"enabled": true,
"host": "192.168.1.70",
"host": "192.168.1.31",
"port": 3000,
"colors": {
"BigMuffPi": {

View file

@ -2,31 +2,11 @@ const logger = require('./logger.js');
const constants = require('./constants.js');
const timeDiff = require('./util.js').timeDiff;
let active;
let lifetime;
let modep;
const cache = new Map();
function isActive() {
if (active === undefined) {
active = global.config.cache.active;
}
return active;
}
function getLifetime() {
if (lifetime === undefined) {
lifetime = global.config.cache.lifetime * 60000
}
return lifetime;
}
async function fill() {
if (!isActive) {
return;
}
const timestamp = new Date();
logger.debug('filling cache...');
clear();
@ -50,25 +30,11 @@ function clear() {
cache.clear();
}
function validLifetime(timestamp) {
if (timestamp === undefined) {
return false;
}
if (lifetime === 0) {
return true;
}
return (new Date().getTime() - timestamp) <= lifetime;
}
function getValue(key) {
let value = cache.get(key);
if (value === undefined) {
return undefined;
}
if (!validLifetime(value.timestamp)) {
resetValue(key)
return undefined;
}
return cache.get(key).data;
}
@ -189,8 +155,6 @@ function clearBypassedPedals() {
}
module.exports = {
isActive,
getLifetime,
fill,
clear,
getBanks,