Package: redis-record
Redis RecordThis lets you record redis streams and commands so that you can replay them easily at a later time.Under the hood, it usesmcapor zip files as a storage format.Getting Started - Using PythonTo install the redis-record package:pipinstallredis_recordIterating over a recordingfromredis_record.storageimportget_player# open your recordingrecording_dir='my-recordings'name='my-favorite-recording'withget_player(name,recording_dir)asplayer:# you can read messages like thisstream_id,timestamp,data_bytes=player.next_message()# or just iterate over them like thisforstream_id,timestamp,data_bytesinplayer:...Configuring your environmentBy default, we assume that redis is accessible via localhost:6379, but if that's not the case you can change that quite easily.exportREDIS_HOST=localhostexportREDIS_PORT=6379Each command can also accept--host localhost --port 6379arguments as well.RecordTo start an on-demand recording:python-mredis_record.recordmy_recordingTo stop, just Interrupt the script (Ctrl-C).This will create a file at./recordings/my_recording.mcap.ReplayTo replay the file into the system, do:python-mredis_record.replaymy_recordingWhat did I record last week?List recording names.python-mredis_recordlistGet info about a recording.python-mredis_recordinfomy_recordingGetting Started - Using DockerThe recorder is designed to be a long-running process, meaning that you can deploy it as a docker container and just control it using redis commands.This is useful if you want to be able to control the recording remotely and always have the data save to the same place.gitclonehttps://github.com/beasteers/redis-record.gitcdredis-record

docker-composeup-d# to observe the recording processdockerlogsredis-recordRecordTo start a recording, do:python-mredis_recordstartmy_second_recordingTo stop a recording, do:python-mredis_recordstopmy_second_recordingReplayCurrently, the replay container isn't a long-running container so you still need to invoke it like above:python-mredis_record.replaymy_recordingRecording more than streamsThe previous method is designed to capture XADD commands (data added to Redis streams). If you want to capture
other redis commands, we can leverage Redis's MONITOR command to capture all commands.Recordpythonredis_record.record.monitormy_other_recordingBy default, it will capture any of the SET command variants (xadd, set, hmset, hset, hsetnx, lset, mset, msetnx, psetex, setbit, setrange, setex, setnx, getset, json.set, json.mset), but it's easy enough to change!pythonredis_record.record.monitormy_other_recording--record-cmds'[xadd,set]'I was initially going to just do[xadd,set]but figured trying to cover a more general use case as a default would be better.ReplayTo replay:pythonredis_record.replay.monitormy_other_recordingZip FormatThe directory structure is as follows:recordings/
  my_recording/
    data_stream_1/
      12345678-0_12456789-0.zip
      12456789-0_12567890-0.zip
      ...
    my_other_stream/
      ...Inside the zipped files have the redis timestamp as the filename and the data is the serialized bytes of the'd'key in the stream.TODOsrecording expiration (auto-stop a recording after e.g. 1 minute of inactivity)s3 recording file storagealternative exporters - e.g. mp4 - but would need consistent/general format.