centralize options

deepsource-autofix-76c6eb20
Dan Gowans 2023-01-25 13:09:14 -05:00
parent c23206a23f
commit efb2a297f9
2 changed files with 11 additions and 15 deletions

View File

@ -1,14 +1,12 @@
import NodeCache from 'node-cache';
import getPreviousLotIdFromDatabase from './lotOccupancyDB/getPreviousLotId.js';
import getNextLotIdFromDatabase from './lotOccupancyDB/getNextLotId.js';
const timeToLiveMinutes = 2;
const previousLotIdCache = new NodeCache({
stdTTL: timeToLiveMinutes * 60,
const cacheOptions = {
stdTTL: 2 * 60,
useClones: false
});
const nextLotIdCache = new NodeCache({
stdTTL: timeToLiveMinutes * 60
});
};
const previousLotIdCache = new NodeCache(cacheOptions);
const nextLotIdCache = new NodeCache(cacheOptions);
function cacheLotIds(lotId, nextLotId) {
previousLotIdCache.set(nextLotId, lotId);
nextLotIdCache.set(lotId, nextLotId);

View File

@ -3,16 +3,14 @@ import NodeCache from 'node-cache'
import getPreviousLotIdFromDatabase from './lotOccupancyDB/getPreviousLotId.js'
import getNextLotIdFromDatabase from './lotOccupancyDB/getNextLotId.js'
const timeToLiveMinutes = 2
const previousLotIdCache = new NodeCache({
stdTTL: timeToLiveMinutes * 60,
const cacheOptions: NodeCache.Options = {
stdTTL: 2 * 60, // two minutes
useClones: false
})
}
const nextLotIdCache = new NodeCache({
stdTTL: timeToLiveMinutes * 60
})
const previousLotIdCache = new NodeCache(cacheOptions)
const nextLotIdCache = new NodeCache(cacheOptions)
function cacheLotIds(lotId: number, nextLotId: number): void {
previousLotIdCache.set(nextLotId, lotId)