Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
Javascript Map taking several minutes to set 7k keys

I have around 7k database entries I want to set into a map. I loop through the data fetched from the db and set it into the map. However, it takes a very long time (around 3 minutes), to set these keys. Is there a better way to do it rather than just looping over the entries and setting them one by one? I'm using a map for cache and run a task every minute for this cache to be updated, but the map itself takes 3 minutes for all the keys to be set.

I'm setting an object as the value, like so:

const data = await fetchDataFromDb();

for (const element of data) cache.set(element.id, element)

cache here is a class extending map (which makes no changes to set method), having some custom methods.

cache update

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda