Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6796423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:29:16+00:00 2026-05-26T18:29:16+00:00

In my app (node / express / redis), I use some code to update

  • 0

In my app (node / express / redis), I use some code to update several items in DB at the same time:

app.put('myaction', function(req, res){
    // delete stuff
    db.del("key1");
    db.srem("set1", "test");

    // Add stuff
    db.sadd("set2", "test2");
    db.sadd("set3", "test3");
    db.hmset("hash1", "k11", "v11", "k21", "v21");
    db.hmset("hash2", "k12", "v12", "k22", "v22");
    // ...

    // Send response back
    res.writeHead(200, {'content-type': 'application/json'});
    res.write(JSON.stringify({ "status" : "ok" }));

    res.end(); 
});

Can I be sure ALL those actions will be performed before the method returns ? My concern is the asynchronous processing. As I do not use callback function in the db actions, will this be alright ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:29:17+00:00Added an answer on May 26, 2026 at 6:29 pm

    Use the MULTI/EXEC command to create a queue of your commands and execute them in a row. Then use a callback to send a coherent response back (success/failure).
    Note that you must use Redis’ AOF to avoid that – in case of crash – the db state is not coherent with your logic because only a part of the commands in the queue were executed: i.e. MULTI/EXEC is not transactional upon execution. This is a useful reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using node.js and the less compiler middleware: app.configure(function() { // ... app.use(express.compiler({ src:
I'm writing a node.js app using express and mongoose-auth. When I run my app,
I'm running a simple web app backed by node.js, and I'm trying to use
I'm using Jade as templating engine for an app on node.js/express. I don't want
I am developing an app in node.js socke.io redis mysql , so this error
i'm trying to write a simple app with node.js to pull some json from
I'm using jQuery with jsdom in my node.js app. Moreover, I want to use
I'm implementing an authentication system in node.js with express backed by a redis database
I'm trying to use Express in node, install everything okay, compiled, got npm and
I am building an app on node.js using express, and node-mysql driver. There is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.