pbc/libs/cache.js

95 lines
2 KiB
JavaScript
Raw Normal View History

2022-02-08 14:07:59 +01:00
const logger = require('./logger.js');
var banks = undefined;
var pedalboards = undefined;
var defaultPedalboard = undefined;
var currentPedalboard = undefined;
var currentPedals = undefined;
function getBanks() {
return banks;
}
function clearBanks() {
logger.debug('clearing bank(s)');
setBanks(undefined);
}
function setBanks(value) {
logger.debug('caching ' + value.length + ' bank(s)');
banks = value;
}
function getPedalboards() {
return pedalboards;
}
function clearPedalboards() {
logger.debug('clearing pedalboard(s)');
setPedalboards(undefined);
}
function setPedalboards(value) {
logger.debug('caching ' + value.length + ' pedalboard(s)');
pedalboards = value;
}
function getDefaultPedalboard() {
return defaultPedalboard;
}
function clearDefaultPedalboard() {
logger.debug('clearing default pedalboard');
setDefaultPedalboard(undefined);
}
function setDefaultPedalboard(value) {
logger.debug('caching default pedalboard');
defaultPedalboard = value;
}
function getCurrentPedalboard() {
return currentPedalboard;
}
function clearCurrentPedalboard() {
logger.debug('clearing current pedalboard');
setCurrentPedalboard(undefined);
}
function setCurrentPedalboard(value) {
logger.debug('caching current pedalboard');
currentPedalboard = value;
}
function getCurrentPedals() {
return currentPedals;
}
function clearCurrenPedals() {
logger.debug('clearing current pedal(s))');
setCurrentPedals(undefined);
}
function setCurrentPedals(value) {
logger.debug('caching ' + value.length + ' current pedal(s)');
currentPedals = value;
}
module.exports = {
getBanks,
clearBanks,
setBanks,
getPedalboards,
clearPedalboards,
setPedalboards,
getDefaultPedalboard,
clearDefaultPedalboard,
setDefaultPedalboard,
getCurrentPedalboard,
clearCurrentPedalboard,
setCurrentPedalboard,
getCurrentPedals,
clearCurrenPedals,
setCurrentPedals
}