Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redis node library json serialization for list values

Tags:

node.js

redis

I'm trying to create an activity feed list in redis using the redis-node library and had a json serialization question.

If I lpush a value into a key, the values get stored as escaped json, and when I retrieve with lrange, I get a list of escaped json back.

Should I simply iterate over the list items and JSON.parse(item) each, or is there a better more efficient method? Specifically, is there a configuration I can use to avoid the overhead of escaping and unescaping the json values?

like image 814
MonkeyBonkey Avatar asked Sep 25 '26 12:09

MonkeyBonkey


1 Answers

Use JSON.strinfigy(object) when storing your value and use JSON.parse(value) when retrieving it.

like image 180
fent Avatar answered Sep 28 '26 03:09

fent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!