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

  • SEARCH
  • Home
  • 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 8051295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:16:16+00:00 2026-06-05T07:16:16+00:00

for (i=0 ; i < pri.state.totalConversations; i++) { redisclient.lindex(conversationsIDList,i, function(err,reply) { convID = reply;

  • 0
for (i=0 ; i < pri.state.totalConversations; i++) {
            redisclient.lindex("conversationsIDList",i, function(err,reply) { 
            convID = reply;
            console.log("ConvID: " + "i: " + i + " "+  convID);         
});
          if(convID == pri.state.lastUpdatedConversationID)
            break;
            redisclient.hget("conversations", convID, function(err,reply) {
            console.log("ConvID hget: "+ convID + " "+ reply);
                data = JSON.parse(reply);
                console.log("data: " +data);

            });

above is a snippet of my code. redis-cli hget command returns the right answer which confirms that i have the hash setup correctly with the right key and field/values. However, the code snippet above returns “null” for hget, (convID has correct value which is the field for hget) – i dont understand why –

  • 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-06-05T07:16:17+00:00Added an answer on June 5, 2026 at 7:16 am

    convID isn’t going to be set until your redisclient.lindex callback returns. That isn’t going to happen until your for loop has long been exited (since node’s event loop won’t even run until you’ve gotten out of your loop). You’re firing off a whole bunch of asynchronous requests to redisclient and not waiting for any of them to come back.

    It’s somewhat hard for me to tell exactly what you want to do, but you might want to look into flow-of-control libraries like Async.

    It might be possible to define a boolean flag variable (scoped to your module or whatever function initiated your loop) that would be set by your first successful callback and would tell subsequent callbacks to ignore their results. But I’m just guessing. The main problem is that you’re trying to use synchronous flow-of-control in an asynchronous environment.

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

Sidebar

Related Questions

i have two tables one of is users: id int(11) NO PRI NULL auto_increment
I have a table named categories like this: id int(11) NO PRI NULL auto_increment
I want to implement FSM like below First Level Most basic State is BASE_STATE.
I have table design like this: id_a int(10) NO PRI id_b int(10) NO PRI
I have the following table: Transaction_ID int(9) NO PRI NULL auto_increment Datetime date NO
try { final List<String> ar = new ArrayList<String>(); final PRIvariable pri = new PRIvariable();
Note on pri from ps man page: pri PRI priority of the process. Higher
What is the difference between MUL , PRI and UNI in MySQL? I'm working
I am new to qt, qmake, etc. I've created a .pri file that includes:
I have these arrays: $array1 Array ( [0] => Array ( [state] => AE

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.