From 226634041973b8e3e59b0bf83ba809dba716d718 Mon Sep 17 00:00:00 2001 From: Nichelle <8347352+nichellekoh@users.noreply.github.com> Date: Mon, 25 Apr 2022 11:41:01 +0800 Subject: [PATCH] Update cache duration correctly to 5 seconds (#1372) --- apps/status-api/src/controllers/OracleStatusController.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/status-api/src/controllers/OracleStatusController.ts b/apps/status-api/src/controllers/OracleStatusController.ts index cd47cdf6d4..215a841c6f 100644 --- a/apps/status-api/src/controllers/OracleStatusController.ts +++ b/apps/status-api/src/controllers/OracleStatusController.ts @@ -20,13 +20,11 @@ export class OracleStatusController { * @return {Promise} */ @Get('/:address') - async getOracleStatus ( - @Param('address') oracleAddress: string - ): Promise<{ status: OracleStatus }> { + async getOracleStatus (@Param('address') oracleAddress: string): Promise<{ status: OracleStatus }> { const oraclePriceFeed: OraclePriceFeed = await this.cachedGet(`oracle-${oracleAddress}`, async () => { const oracle = await this.client.oracles.getOracleByAddress(oracleAddress) return (await this.client.oracles.getPriceFeed(oracle.id, oracle.priceFeeds[0].token, oracle.priceFeeds[0].currency, 1))[0] - }, 5000) + }, 5) // cache result for 5 seconds const nowEpoch = Date.now() const latestPublishedTime = oraclePriceFeed.block.medianTime * 1000