Skip to content

Commit

Permalink
Update cache duration correctly to 5 seconds (#1372)
Browse files Browse the repository at this point in the history
  • Loading branch information
nichellekoh authored Apr 25, 2022
1 parent 60f0d27 commit 2266340
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions apps/status-api/src/controllers/OracleStatusController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ export class OracleStatusController {
* @return {Promise<OracleStatus>}
*/
@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
Expand Down

0 comments on commit 2266340

Please sign in to comment.