Redis Storage
NSB's optional payload caching mechanism. This page explains what Redis does inside NSB and why it matters; for the YAML fields that control it, see Configuration โ Database Settings.
What Redis Does in NSBโ
When use_db: true is set, payloads are stored in a Redis database rather than transmitted directly. The key for each stored payload is routed through NSB, and the receiving side retrieves the full payload from Redis using that key. When use_db: false, payloads are transmitted directly through NSB without persistent storage.
When It Helpsโ
Caching is most valuable for large payloads โ anything that would exceed network buffer sizes if relayed in full through the bridge. For small test payloads (as in the Quickstart), direct transmission (use_db: false) is simpler and requires no Redis server at all.
The Payload Caching Sequenceโ
NSB2 decouples payload content from the relay path using a fast, in-memory key-value store:
- When
NsbAppClient.send()is called โ payload stored in Redis โ key returned (<32 bytes>) - This key is transmitted through the bridge instead of the full payload
- When
NsbSimClient.fetch()retrieves the entry โ uses the key to check out the full payload from Redis - When
NsbSimClient.post()is called โ payload re-cached โ key transmitted back through bridge - When
NsbAppClient.receive()retrieves the entry โ uses the key to check out the full payload
The daemon never sees the payload content โ only the key and metadata.
Why Size Independence Mattersโ
If payloads were transmitted through the bridge in full (as in NSB v1), payloads larger than the host environment's buffer size would need to be chunked at each leg of the pipeline โ adding computational overhead, bandwidth consumption, and latency. By routing only a fixed-size key (<32 bytes>) regardless of payload size, NSB2 makes bridge performance independent of payload size โ a 10-byte message and a 10-megabyte message cost the same to relay.
This is implemented through the DBConnector abstraction (store(), checkOut(), peek()), with Redis as the default implementation. See Deep Architecture โ Cache Abstraction for the full interface contract and possible alternative implementations.
Go Deeperโ
- Configuration โ Database Settings โ
use_db,db_address,db_port,db_numfields and Redis startup commands - Deep Architecture โ Payload Caching โ the same sequence in full architectural context
- Performance Evaluation โ empirical memory and latency measurements with caching enabled