0

I am trying to set up a redis cach system. I have Json data coming in and I want to store it in a specific way! Currently im trying to just have an ordered list as there will be lots of data stored here before deleting. The basic data i am using is

{
    user_id: "123456789"
    acc_x: "123456789"
    acc_y: "123456789"
    acc_z: "123456789"
    time: "123456789"
}

The way I would like to store it in redis is something like this:

user_id:"123456789" -> acc_x:"123456789" , acc_y:"123456789" ,acc_z:"123456789" , time:"123456789"

Ive tried with two variables like this

//Where temp is a place holder for values
client.mset("AccelX", temp_x,"AccelY", temp_y, redis.print);

This approach does not work and I am just confused as to how to do it if anyone knows a way or any documentation that would be great

1 Answer 1

1

You should instead use

client.hmset ("123456789", "acc_x", "val 1", "acc_y", "val 2")

Refer the following links :

http://redis.io/commands/hmset

https://github.com/mranney/node_redis/blob/4f9c6bd21912b1404089777d4e409d7a55ce1250/test.js

Sign up to request clarification or add additional context in comments.

Comments

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.