UNPKG

@golemio/pid

Version:
35 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataCacheManager = void 0; const RegionalBusGtfsCacheRepository_1 = require("../../vehicle-positions/workers/runs/data-access/cache/RegionalBusGtfsCacheRepository"); const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors"); const cache_1 = require("../data-access/cache"); const Di_1 = require("../ioc/Di"); const RopidGtfsContainerToken_1 = require("../ioc/RopidGtfsContainerToken"); class DataCacheManager { static getInstance() { if (!DataCacheManager._instance) { DataCacheManager._instance = new DataCacheManager(); } return DataCacheManager._instance; } constructor() { this.staticFileRepository = new cache_1.StaticFileRedisRepository(); this.runTripsRepository = new cache_1.RunTripsRedisRepository(); this.blockStopsRepository = Di_1.RopidGtfsContainer.resolve(RopidGtfsContainerToken_1.RopidGtfsContainerToken.BlockStopsRedisRepository); this.regionalBusGtfsLookupCacheRepository = new RegionalBusGtfsCacheRepository_1.RegionalBusGtfsCacheRepository(); } async cleanCache() { try { await this.staticFileRepository.truncate(true); await this.runTripsRepository.truncate(true); await this.blockStopsRepository.truncate(true); await this.regionalBusGtfsLookupCacheRepository.truncate(true); } catch (err) { throw new golemio_errors_1.GeneralError("DataCacheManager: Failed to clean cache", this.constructor.name, err); } } } exports.DataCacheManager = DataCacheManager; //# sourceMappingURL=DataCacheManager.js.map