redis / rueidis

A fast Golang Redis client that supports Client Side Caching, Auto Pipelining, Generics OM, RedisJSON, RedisBloom, RediSearch, etc.
Apache License 2.0
2.34k stars 149 forks source link

Hashrepository with nested json, indexes and search #611

Closed hamidrabedi closed 4 weeks ago

hamidrabedi commented 4 weeks ago

Can you please provide and example with hash repository to create multiple nested structs, and index the nested fields and do search on them? I could not make this work at all.

Thank you.

rueian commented 4 weeks ago

Hi @hamidrabedi,

For nested structs, you need to use the JSONRepository instead. See https://github.com/redis/rueidis/tree/main/om#object-mapping-limitation

hamidrabedi commented 4 weeks ago

hi there, thanks for the response.

I'm trying to find the best way to store sessions and do filtering on them, so i was wondering if i make all of them into one json or like nested json and then do the filtering on hash map, will it be faster than json? or not a huge difference?

rueian commented 4 weeks ago

Be careful that Redis is single thread at core and at transit, therefore, it does not suite for storing large objects and objects that their sizes vary hugely. You should avoid storing large object or your Redis will perform badly.

hamidrabedi commented 4 weeks ago

thanks for the heads up, just saw the docs. we probable will cluster our redis to be able to use multiple threads as well.

i think I got my answer. thanks.