Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!