0

Looking at Redis streams and building indexes on a stream ( like EventStore does) , this works pretty well and i can get a bunch of entries in a stream except i cant find a nice way to return all the records by id eg like an MGET. This is a simplified version of what im looking at.

        var records = await conn.StreamRangeAsync(indexStreamName, nextPosition, null, BatchSize);
        if (records.Any())
        {
             var results = new List<Event>();
             foreach (var record  in records)
             {
                  var msgs = await conn.StreamRangeAsync(record.Values.FirstOrDefault(x => x.Name == "stream").Value.ToString(), record.Values.FirstOrDefault(x => x.Name == "key").Value, null, 1);
                        results.Add(ToEvent(msgs.First()));
              }
              await playEvents(results.ToArray());
        }

Obviously this is very inefficient and i was wondering is there some way to get this from the server in 1 request.

I also considered streams building other streams however it will result in message duplication and our messages can get large. Yes i could than put all messages in a set but 2 levels of indirection is a bridge too far.

user1496062
  • 1,309
  • 1
  • 7
  • 22

1 Answers1

0

Still hoping for a better answer but one way you can do this is

Is have the messages in a parent stream and all the indexes being smaller streams not ideal since the larger stream is logically an aggregation and not the real data but will work ok.

user1496062
  • 1,309
  • 1
  • 7
  • 22