redigo icon indicating copy to clipboard operation
redigo copied to clipboard

Support for RedisJSON

Open psankar opened this issue 6 years ago • 5 comments

https://oss.redislabs.com/redisjson/ Redis JSON is developed at RedisLabs to give a native JSON datatype to save complex objects in Redis. We can do some operations like INCR on the individual members of a complex struct (for example increment only age in a Person object).

I came across this RedisJSON via an excellent blog post https://itnext.io/storing-go-structs-in-redis-using-rejson-dab7f8fc0053

However, I am a bit uncomfortable using a library other than redigo for my golang programs to talk with redis.

Are there any plans to support the RedisJSON via redigo ? If so, is there any ongoing work that is happening for it and any rough idea on when this might land in redigo ? Thanks.

psankar avatar Jun 26 '19 09:06 psankar

Hello @psankar

AFAIK redigo doesn't need any additional effort to work with RedisJSON as redigo isn't strongly typed - just conn.Do("json.set"...) to call the module's SET command and so forth.

itamarhaber avatar Jun 26 '19 13:06 itamarhaber

Hello @itamarhaber , yes I can do conn.Do("json.set"...) but I was looking for a better way to automatically (un)marshal golang structs from/to json while working with redis.

sankarp-kavach avatar Jun 26 '19 16:06 sankarp-kavach

Hello @itamarhaber , yes I can do conn.Do("json.set"...) but I was looking for a better way to automatically (un)marshal golang structs from/to json while working with redis.

Why not use ScanStruct ?

pidgy avatar Jul 19 '19 18:07 pidgy

There is some scenario which are difficult to do with marshelling/flat JSON like updating the one Individual key of JSON Object is there any way we can do this without first get the struct and then set the field (means 2 Network RTT)

2dev2 avatar Dec 11 '19 21:12 2dev2

@2dev2 do you mean like this command? https://redis.io/commands/json.set/

gkorland avatar Dec 13 '19 05:12 gkorland

I believe this is answered above (just updated the URL). If that's not the case please feel free to reply and we can re-open.

stevenh avatar Jan 28 '24 15:01 stevenh