diff --git a/example_config.json b/example_config.json index c629d35..50adfc9 100644 --- a/example_config.json +++ b/example_config.json @@ -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": { diff --git a/libs/cache.js b/libs/cache.js index 598d61f..d532d53 100644 --- a/libs/cache.js +++ b/libs/cache.js @@ -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,