From c5b584423373d9be2ea20d91bb95b872e4580a1d Mon Sep 17 00:00:00 2001 From: velvettear Date: Thu, 24 Mar 2022 23:35:51 +0100 Subject: [PATCH] removed cache options --- example_config.json | 10 +++------- libs/cache.js | 36 ------------------------------------ 2 files changed, 3 insertions(+), 43 deletions(-) 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,