Browse Source

Improve caching

pull/1320/head
Thomas 3 years ago
parent
commit
40b92db304
  1. 15
      apps/api/src/app/benchmark/benchmark.service.ts

15
apps/api/src/app/benchmark/benchmark.service.ts

@ -73,6 +73,7 @@ export class BenchmarkService {
} }
const allTimeHighs = await Promise.all(promises); const allTimeHighs = await Promise.all(promises);
let storeInCache = true;
benchmarks = allTimeHighs.map((allTimeHigh, index) => { benchmarks = allTimeHighs.map((allTimeHigh, index) => {
const { marketPrice } = const { marketPrice } =
@ -85,6 +86,8 @@ export class BenchmarkService {
allTimeHigh, allTimeHigh,
marketPrice marketPrice
); );
} else {
storeInCache = false;
} }
return { return {
@ -100,11 +103,13 @@ export class BenchmarkService {
}; };
}); });
await this.redisCacheService.set( if (storeInCache) {
this.CACHE_KEY_BENCHMARKS, await this.redisCacheService.set(
JSON.stringify(benchmarks), this.CACHE_KEY_BENCHMARKS,
ms('4 hours') / 1000 JSON.stringify(benchmarks),
); ms('4 hours') / 1000
);
}
return benchmarks; return benchmarks;
} }

Loading…
Cancel
Save