Expand description
Trine KV is an embedded LSM MVCC key-value database.
Use Trine KV when an application needs a local key/value store with
persistent storage, atomic batches, snapshots, range scans, prefix scans,
and optimistic transactions. The primary API is async-first; synchronous
callers use the explicit *_sync adapters.
§Quick start
Db::open and Db::open_sync are path-first. Passing a path opens a
persistent database. Use DbOptions::memory() when the database should live
only in memory.
use trine_kv::Db;
let db = Db::open_sync("target/doc-example-basic")?;
db.put_sync(b"user:1", b"Ada")?;
let value = db.get_sync(b"user:1")?;
assert_eq!(value, Some(b"Ada".to_vec()));§Core concepts
Dbis the database handle. DirectDbread and write methods operate on the built-in default bucket.Bucketis a handle for an optional named bucket with its own options, memtables, tables, filters, and compaction state.WriteBatchgroups puts, point deletes, and range deletes into one atomic commit.Snapshotpins a committed sequence so repeated reads see a stable view while newer writes continue.Transactionrecords reads and stages writes, then rejects commit if a later committed write conflicts with the read set.
§Durability
Persistent databases default to safety-first durability for confirmed
writes. Lower durability modes such as DurabilityMode::Buffered are
available through WriteOptions for data that can tolerate losing recent
confirmed writes after a crash.
Re-exports§
pub use bucket::Bucket;pub use bucket::BucketName;pub use bucket::BucketReader;pub use db::Db;pub use db::IntoOpenOptions;pub use db::MaintenanceBudget;pub use db::MaintenanceOutcome;pub use error::Error;pub use error::Result;pub use iterator::Direction;pub use iterator::Iter;pub use iterator::LazyIter;pub use iterator::LazyKeyValue;pub use iterator::LazyValue;pub use options::BlobGcRatio;pub use options::BlobLevelMergePolicy;pub use options::BucketOptions;pub use options::CompressionProfile;pub use options::DbOptions;pub use options::DurabilityMode;pub use options::FailOnCorruptionPolicy;pub use options::FilterPolicy;pub use options::HostStorageBackend;pub use options::IndexSearchPolicy;pub use options::PrefixFilterPolicy;pub use options::StorageMode;pub use options::WriteOptions;pub use prefix::PrefixExtractor;pub use recovery::RecoveryReport;pub use runtime::CancellationToken;pub use runtime::RuntimeCapabilities;pub use runtime::RuntimeMode;pub use runtime::RuntimeOptions;pub use snapshot::Snapshot;pub use stats::DbStats;pub use transaction::Transaction;pub use transaction::TransactionOptions;pub use types::CommitInfo;pub use types::KeyRange;pub use types::KeyValue;pub use types::Sequence;pub use types::Value;pub use write_batch::WriteBatch;
Modules§
- bucket
- Bucket handles and bucket-bound readers.
- db
- Database open, read, write, scan, and maintenance APIs.
- error
- Error and result types returned by Trine KV.
- iterator
- Forward and reverse iterators over committed rows.
- options
- Database, bucket, write, storage, runtime, and durability options.
- prefix
- Prefix extraction policies used by prefix filters.
- recovery
- Startup recovery helpers and recovery reports.
- runtime
- Runtime selection, capabilities, and cancellation support.
- search
- Search policy helpers for table indexes.
- snapshot
- Snapshot handles for repeatable reads.
- stats
- Live database statistics exposed to callers.
- transaction
- Optimistic transaction API.
- types
- Core key, value, range, sequence, and commit types.
- write_
batch - Atomic write batch types.
Structs§
- Point
Value - Value returned by
BucketReader::get.
Type Aliases§
- Snapshot
Sequence - Sequence number pinned by a snapshot.