change caching and repository api to include system id initializer

This commit is contained in:
2025-01-07 20:02:12 -08:00
parent 1958af2593
commit e7e915a8b1
2 changed files with 25 additions and 26 deletions

View File

@@ -8,11 +8,11 @@ export interface ApiBasedRepositoryCache {
etasForStopId?: {
[stopId: string]: IEta[],
},
stopsBySystemId?: {
[systemId: string]: IStop[],
stopsByStopId?: {
[stopId: string]: IStop,
},
shuttlesByShuttleId?: {
[shuttleId: string]: IShuttle[],
shuttleByShuttleId?: {
[shuttleId: string]: IShuttle,
},
// To speed things up, implement caches for other data later
}
@@ -34,6 +34,7 @@ const defaultTtls: ApiBasedRepositoryMillisecondTTLs = {
export class ApiBasedRepository implements GetterRepository {
constructor(
private systemId: string,
private initialCache: ApiBasedRepositoryCache | undefined = emptyCache,
private ttls: ApiBasedRepositoryMillisecondTTLs = defaultTtls,
) {