Change Feeds
Change feeds provide a real-time stream of write events from the database.
Subscribing
let mut feed = db.subscribe()?;
// Process events as they arrivewhile let Some(event) = feed.next() { match event { ChangeEvent::Put { key, value, commit_ts } => { println!("Write: {} = {:?} at ts={}", key, value, commit_ts); } ChangeEvent::Delete { key, commit_ts } => { println!("Delete: {} at ts={}", key, commit_ts); } }}Filtering
Filter change feeds by key prefix:
let mut feed = db.subscribe_prefix("orders/")?;// Only receives events for keys starting with "orders/"Use Cases
- Materialized views: Keep derived data up to date
- Replication: Stream changes to a secondary system
- Event processing: Trigger business logic on data changes
- Audit logging: Record all mutations for compliance
Impact on Write Path
When subscribers are active, the write path falls back from the fast path to the channel path to ensure event delivery. This adds ~160µs per write.
// has_subscribers flag is set eagerly when:// 1. db.subscribe() is called