Jump to content

Nested object in redis from node.js?

Go to solution Solved by WWicket,

Redis is flat. You can either flatten the object (think JSON.stringify) or break it up into separate hash tables (ex. https://redislabs.com/redis-best-practices/data-storage-patterns/object-hash-storage/). 

 

ps: the flat module for npm is nifty. 

I use a redis database in my program for simple key storage and I wanted to move my .json log file to the redis server for simplicity sake.  My question is, how do you store nested objects in redis?

 

Spoiler

CPU: 5800x

GPU: 1070ti

HDD: Seagate 3TB
SSD: 1TB WD NVME

RAM: 32GB ddr4 3200

HEADPHONES: DT990 pro 250ohm limited edition black

MONITER: BenQ xl2536

CASE: s340 elite hyperbeast

KEYBOARD: nk87- zilent switches

MOUSE: G403 Hero

 

Link to comment
https://linustechtips.com/topic/1118330-nested-object-in-redis-from-nodejs/
Share on other sites

Link to post
Share on other sites

Redis is flat. You can either flatten the object (think JSON.stringify) or break it up into separate hash tables (ex. https://redislabs.com/redis-best-practices/data-storage-patterns/object-hash-storage/). 

 

ps: the flat module for npm is nifty. 

Link to post
Share on other sites

For anyone in the future, I ended up turning the object into a string with JSON.stringify(obj) saving it to redis, and whenever I wanted it I just did JSON.parse(result) on the saved object/result to turn it back into an object.

Spoiler

CPU: 5800x

GPU: 1070ti

HDD: Seagate 3TB
SSD: 1TB WD NVME

RAM: 32GB ddr4 3200

HEADPHONES: DT990 pro 250ohm limited edition black

MONITER: BenQ xl2536

CASE: s340 elite hyperbeast

KEYBOARD: nk87- zilent switches

MOUSE: G403 Hero

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×