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

212
Views
actualizar datos en caché usando node-cache

Estoy usando Nextjs y guardé en caché algunas API usando node-cache. si los datos no existen en el caché, solicito la API y los coloco en el caché del servidor; de lo contrario, obtengo datos del caché. Pero esta API puede actualizarse cada 1 mes desde el backend. No sé cómo saber cuándo se actualizan estos datos y cuándo debería llamar a la API y actualizar el caché.

 const NodeCache = require("node-cache"); const myCache = new NodeCache(); let navigation = myCache.get("navigation"); let footer = myCache.get("footer"); if (navigation !== undefined) { response = { navigation: navigation, footer: footer, }; } else { await Promise.all([promise1]).then( (res) => { myCache.set("navigation", res[0].data['navigation-menu'], 3600); myCache.set("footer", res[0].data['footer-menu'], 3600); response = { navigation: res[0].data['navigation-menu'], footer: res[0].data['footer-menu'], }; }, ); }

Hago caducar el caché cada 1 hora, pero creo que esta no es la mejor solución

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!