02 · Queryable views

Lens

Lens is the read-side: derived materialized views over one or many Strands. Snapshots, sub-DBs, fast iteration over arbitrary keyspaces, batched writes, cache-aware compaction. The source log is never touched.

Concepts

What you’re working with.

  • 01Read-side projections of one or more Strands.
  • 02Snapshots, sub-DBs, batched writes, cache-aware compaction.
  • 03Source logs are never mutated.
  • 04Iteration over arbitrary keyspaces, byte-prefix scans.
Code

A handful of lines.

use lens::{Lens, LensConfig};

let lens = Lens::open("./.weave/views/posts", LensConfig::default()).await?;
let mut tx = lens.batch();
tx.put(b"post:42", b"hello, world")?;
tx.commit().await?;

for (k, v) in lens.scan_prefix(b"post:") {
    println!("{:?} -> {:?}", k, v);
}

Ready to build?

Start with the SDK or load the agent context. Every library is independently documented and versioned.