preload caches on startup
parent
3f8c331cd3
commit
13b9b15c2f
2
app.js
2
app.js
|
|
@ -19,6 +19,7 @@ import routerLotOccupancies from './routes/lotOccupancies.js';
|
||||||
import routerWorkOrders from './routes/workOrders.js';
|
import routerWorkOrders from './routes/workOrders.js';
|
||||||
import routerReports from './routes/reports.js';
|
import routerReports from './routes/reports.js';
|
||||||
import routerAdmin from './routes/admin.js';
|
import routerAdmin from './routes/admin.js';
|
||||||
|
import { preloadCaches } from './helpers/functions.cache.js';
|
||||||
import * as configFunctions from './helpers/functions.config.js';
|
import * as configFunctions from './helpers/functions.config.js';
|
||||||
import * as printFunctions from './helpers/functions.print.js';
|
import * as printFunctions from './helpers/functions.print.js';
|
||||||
import * as dateTimeFns from '@cityssm/utils-datetime';
|
import * as dateTimeFns from '@cityssm/utils-datetime';
|
||||||
|
|
@ -32,6 +33,7 @@ import { useTestDatabases } from './data/databasePaths.js';
|
||||||
import Debug from 'debug';
|
import Debug from 'debug';
|
||||||
const debug = Debug(`lot-occupancy-system:app:${process.pid}`);
|
const debug = Debug(`lot-occupancy-system:app:${process.pid}`);
|
||||||
databaseInitializer.initializeDatabase();
|
databaseInitializer.initializeDatabase();
|
||||||
|
preloadCaches();
|
||||||
const _dirname = '.';
|
const _dirname = '.';
|
||||||
export const app = express();
|
export const app = express();
|
||||||
app.disable('X-Powered-By');
|
app.disable('X-Powered-By');
|
||||||
|
|
|
||||||
8
app.ts
8
app.ts
|
|
@ -24,6 +24,8 @@ import routerWorkOrders from './routes/workOrders.js'
|
||||||
import routerReports from './routes/reports.js'
|
import routerReports from './routes/reports.js'
|
||||||
import routerAdmin from './routes/admin.js'
|
import routerAdmin from './routes/admin.js'
|
||||||
|
|
||||||
|
import { preloadCaches } from './helpers/functions.cache.js'
|
||||||
|
|
||||||
import * as configFunctions from './helpers/functions.config.js'
|
import * as configFunctions from './helpers/functions.config.js'
|
||||||
import * as printFunctions from './helpers/functions.print.js'
|
import * as printFunctions from './helpers/functions.print.js'
|
||||||
import * as dateTimeFns from '@cityssm/utils-datetime'
|
import * as dateTimeFns from '@cityssm/utils-datetime'
|
||||||
|
|
@ -48,6 +50,12 @@ const debug = Debug(`lot-occupancy-system:app:${process.pid}`)
|
||||||
|
|
||||||
databaseInitializer.initializeDatabase()
|
databaseInitializer.initializeDatabase()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PRELOAD CACHES
|
||||||
|
*/
|
||||||
|
|
||||||
|
preloadCaches()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* INITIALIZE APP
|
* INITIALIZE APP
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,5 @@ export declare function getWorkOrderTypeById(workOrderTypeId: number): Promise<r
|
||||||
export declare function getWorkOrderMilestoneTypes(): Promise<recordTypes.WorkOrderMilestoneType[]>;
|
export declare function getWorkOrderMilestoneTypes(): Promise<recordTypes.WorkOrderMilestoneType[]>;
|
||||||
export declare function getWorkOrderMilestoneTypeById(workOrderMilestoneTypeId: number): Promise<recordTypes.WorkOrderMilestoneType | undefined>;
|
export declare function getWorkOrderMilestoneTypeById(workOrderMilestoneTypeId: number): Promise<recordTypes.WorkOrderMilestoneType | undefined>;
|
||||||
export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string): Promise<recordTypes.WorkOrderMilestoneType | undefined>;
|
export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string): Promise<recordTypes.WorkOrderMilestoneType | undefined>;
|
||||||
|
export declare function preloadCaches(): void;
|
||||||
export declare function clearCacheByTableName(tableName: string, relayMessage?: boolean): void;
|
export declare function clearCacheByTableName(tableName: string, relayMessage?: boolean): void;
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,15 @@ export async function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrde
|
||||||
workOrderMilestoneTypeLowerCase);
|
workOrderMilestoneTypeLowerCase);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
export function preloadCaches() {
|
||||||
|
debug('Preloading caches');
|
||||||
|
void getLotOccupantTypes();
|
||||||
|
void getLotStatuses();
|
||||||
|
void getLotTypes();
|
||||||
|
void getOccupancyTypes();
|
||||||
|
void getWorkOrderTypes();
|
||||||
|
void getWorkOrderMilestoneTypes();
|
||||||
|
}
|
||||||
function clearWorkOrderMilestoneTypesCache() {
|
function clearWorkOrderMilestoneTypesCache() {
|
||||||
workOrderMilestoneTypes = undefined;
|
workOrderMilestoneTypes = undefined;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -298,6 +298,16 @@ export async function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function preloadCaches(): void {
|
||||||
|
debug('Preloading caches')
|
||||||
|
void getLotOccupantTypes()
|
||||||
|
void getLotStatuses()
|
||||||
|
void getLotTypes()
|
||||||
|
void getOccupancyTypes()
|
||||||
|
void getWorkOrderTypes()
|
||||||
|
void getWorkOrderMilestoneTypes()
|
||||||
|
}
|
||||||
|
|
||||||
function clearWorkOrderMilestoneTypesCache(): void {
|
function clearWorkOrderMilestoneTypesCache(): void {
|
||||||
workOrderMilestoneTypes = undefined
|
workOrderMilestoneTypes = undefined
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue