Redis Stream Data Structure

32 views
Skip to first unread message

Kit Karson

unread,
Jan 23, 2022, 12:30:32 PM1/23/22
to Redis DB
Hi All,

 am trying to understand the redis stream data structure. Why redis uses a map instead of simple bucket?

Lets imagine I would like to raise an event whenever a new book is inserted.

    class Book {
   
                    String id;
                    String name;
                    Stirng title;
                    String author;
                    String isbn;
                    ...
   
            }


Should I be adding into stream like this?

        XADD bookstream * id 1 name mybook title mytitle author ram isbn 1223232

I would like to do this way because the consuming applications would be interested in whole event object. Not partial information from a map!

        XADD bookstream * book [book-object-binary-message]


**Questions:**

 - Can I send binary message via stream with a single key as I showed?
 - In that case, key does not seem to add any value here! Because we send an object as binary message. in a `bookstream`, I can not expect an `animal` event. Redis also does not support partition inside stream. So what is the use of key?

Viktor Söderqvist

unread,
Jan 24, 2022, 6:00:49 AM1/24/22
to redi...@googlegroups.com
Yes, this is possible. The values can be any binary data. Even the field
names can be any binary data.

Kit Karson

unread,
Jan 24, 2022, 10:00:13 AM1/24/22
to Redis DB
Thanks. I also would like to understand the use of below approach. where it will be useful?


  XADD bookstream * id 1 name mybook title mytitle author ram isbn 1223232
Reply all
Reply to author
Forward
0 new messages