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 7942409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:57:41+00:00 2026-06-03T23:57:41+00:00

I am using Node.js and a Redis Database . I am new to Redis

  • 0

I am using Node.js and a Redis Database . I am new to Redis .

I am using the https://github.com/mranney/node_redis driver for node.

Initialization code –

var redis = require("redis"),
client = redis.createClient();

I tried setting up some key value pairs –

client.hset("users:123" ,"name", "Jack");

I wish to know I can get the name parameter from Redis via Node .

I tried

var name = client.hget("users:123", "name");  //returns 'true'

but it just returns ‘true’ as the output. I want the value ( i.e – Jack )
What is the statement I need to use ?

  • 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-03T23:57:42+00:00Added an answer on June 3, 2026 at 11:57 pm

    This is how you should do it:

    client.hset("users:123", "name", "Jack");
    // returns the complete hash
    client.hgetall("users:123", function (err, obj) {
       console.dir(obj);
    });
    
    // OR
    
    // just returns the name of the hash
    client.hget("users:123", "name", function (err, obj) {
       console.dir(obj);
    });
    

    Also make sure you understand the concept of callbacks and closures in JavaScript as well as the asynchronous nature of node.js. As you can see, you pass a function (callback or closure) to hget. This function gets called as soon as the redis client has retrieved the result from the server. The first argument will be an error object if an error occurred, otherwise the first argument will be null. The second argument will hold the results.

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

Sidebar

Related Questions

Currently I'm using https://github.com/mranney/node_redis as my node redis client. client.retry_delay is set to 250ms
I'm using Redis To Go in combination with the https://github.com/mranney/node_redis library. Redis gives me
I am using https://github.com/mranney/node_redis and trying to update a set with multiple values at
I am using redis and node (with node_redis ) and I would like to
I'm using socket.io and Redis together with node.js - code below. I'm definitely being
I'm using the Node.js module node_redis: var data = [ {'name':'matt', 'id':'333' } ,
Must be missing something here, but I'm using Node_redis as Node.js client for Redis.
I'm using Node.js w/ node_redis and am looping through an object and looking up
Ok, so I am developing a multiplayer game using: Node.js, Sockets.io & Redis Anyway
I have the following express node.js app. It's using the 'redis' npm package. app.get(/test,function(req,res){

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.