0

I have a service that uses Redis to cache some requests, but recently some of the fetches have been a little slow and I wasn't able to find any actionable items to resolve it.

// fetch
await this.cache.get(cacheKey)

I'm currently using Promise.any with a setTimeout function, but wondering if there is a built-in way to limit the amount of time this request takes? I.e. Timeout after 15 ms?

Promise.any([
    new Promise((resolve) => setTimeout(resolve, 15)),
    this.cache.get(cacheKey)
])
Panpaper
  • 451
  • 1
  • 6
  • 16

0 Answers0