Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
How can i update values stored in map to database after every 1 hour while synchronizing incoming requests on route which updates map continously

I am facing a problem to update the values stored in map to database because the map is updating continously due to incoming requests on the route and at the same time I want to update values in database periodically with the help of map. How to synchronize both the operations?

const url_count = new Map();

async function update_count(){
 
    // update value in mongodb 
    
}
app.get('/teeny/:code', async (req, res) => {
    try {
        const url = await Link_URL.findOne({
            _id : req.params.code
        })
        if (url) {
          if(url_count.has(req.params.code)){
            const val = url_count.get(req.params.code);
            url_count.set(req.params.code,val+1);
            update_count();
          }
          else{
              url_count.set(req.params.code,1);
          }  
            return res.redirect(url.URL);
        } else {
            return res.status(404).json('No URL Found')
        }
    }
    catch (err) {
        console.error(err)
        res.status(500).json('Server Error')
    }
})
cron.schedule('* * 1 * *', update_count);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could use Later for a simple solution... here you would be collecting all those values and then insert them at a specified time that you specified in later..

For something heavier, you could go for Bull or for Rabbot

If you want to kill a lion, go for Node-Celery... but make sure to have python installed.

Basically, all you need is a queuing system to collect[in a queue] all those tasks that you want to save later...

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda