Skip to main content
The cache bus propagates invalidation events, not full values. Instances with the same id stay consistent across tabs, workers, and custom transports.

Built-in buses

Every createStorage() instance composes three buses:
  1. Registry channel: in-process sync between instances sharing id
  2. BroadcastChannel: cross-tab sync in browsers (@brushy/storage:{id})
  3. Custom bus: optional options.bus

CacheBus interface

Custom server ↔ client bus

Use WebSockets, SSE, or message queues to invalidate keys after mutations on the server:
Design custom buses to invalidate keys. Remote set events drop the local copy without fetching the remote value; replicate values explicitly if needed.

Composing buses

Event handling

Events include source so the originating instance ignores its own broadcasts.