Redis streams as a pure data structure

Redis streams as a pure data structure

For now let’s just focus on that usage pattern: XADD to add stuff, XRANGE (but also XREAD) in order to fetch back ranges (depending on what you want to do), and let’s see why I claim Streams are so powerful as a data structure. Those are the numbers for storing one million of matches in the configurations exposed previously:

Sorted Set + Hash memory usage = 220 MB (242 RSS)
Stream memory usage = 16.8 MB (18.11 RSS)

This is more than an order of magnitude difference (13 times difference exactly), and it means that use cases that yesterday were too costly for in-memory now are perfectly viable. ## Time series

One important thing to note is, in my opinion, how the usage above where e used a Stream to represent a tennis match was semantically *very different* than using a Redis Stream for a time series.

Source: antirez.com