0

Helo guys i'm just new in nodejs and redis but i don't have any idea on inserting data in redis using nodejs/express. Can you please help me or provide me an example? Thanks

2

1 Answer 1

2

You can use the most popular (at least for now) client module: redis

Example (from documentation)

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

// if you'd like to select database 3, instead of 0 (default), call
// client.select(3, function() { /* ... */ });

client.on("error", function (err) {
    console.log("Error " + err);
});

client.set("string key", "string val", redis.print);
client.hset("hash key", "hashtest 1", "some value", redis.print);
client.hset(["hash key", "hashtest 2", "some other value"], redis.print);
client.hkeys("hash key", function (err, replies) {
    console.log(replies.length + " replies:");
    replies.forEach(function (reply, i) {
        console.log("    " + i + ": " + reply);
    });
    client.quit();
});
Sign up to request clarification or add additional context in comments.

1 Comment

Sounds like you need to look into HTML forms and HTTP REST the html form will POST data to the Express server. The express server will register a route, within that route you will add the data to redis. app.post("/route",req,res,next(){ // redis code here}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.