Stream Import/Export

RIOT-X provides commands to import and export data from and to Redis streams.

Stream Import

The stream-import command reads data from a stream and writes it to Redis.

The basic usage is:

riotx stream-import STREAM...

For the full usage, run:

riotx stream-import --help
Example: Import stream into hashes
riotx stream-import stream:beers --idle-timeout 1s hset beer:#{id}

Stream Export

The stream-export command enables Redis CDC to a Redis stream.

riotx stream-export SOURCE TARGET [OPTIONS]

For the full usage, run:

riotx stream-export --help
Example: Export stream to another Redis instance
riotx stream-export redis://localhost:6379 redis://localhost:6380 --mode live

redis-cli -p 6380 xread COUNT 3 STREAMS stream:export 0-0
1) 1) "stream:export"
   2) 1) 1) "1718645537588-0"
         2)  1) "key"
             2) "order:4"
             3) "time"
             4) "1718645537000"
             5) "type"
             6) "hash"
             7) "ttl"
             8) "-1"
             9) "mem"
            10) "136"
            11) "value"
            12) "{\"order_date\":\"2024-06-13 22:19:35.143797\",\"order_id\":\"4\"}"

Stream Export Field Descriptions

Each exported stream entry contains the following fields:

Field Description

key

The Redis key that was modified

time

Timestamp of the change event (milliseconds since epoch)

type

Redis data type (e.g., hash, string, set, zset, list, stream, json)

ttl

Time-to-live in seconds (-1 indicates no expiration)

mem

Memory usage of the key in bytes

value

JSON-serialized representation of the key’s value