Expand description
§redb
A simple, portable, high-performance, ACID, embedded key-value store.
redb is written in pure Rust and is loosely inspired by lmdb. Data is stored in a collection of copy-on-write B-trees. For more details, see the design doc.
§Features
- Zero-copy, thread-safe,
BTreeMap
based API - Fully ACID-compliant transactions
- MVCC support for concurrent readers & writer, without blocking
- Crash-safe by default
- Savepoints and rollbacks
§Example
use redb::{Database, Error, ReadableTable, TableDefinition};
const TABLE: TableDefinition<&str, u64> = TableDefinition::new("my_data");
#[cfg(not(target_os = "wasi"))]
fn main() -> Result<(), Error> {
let file = tempfile::NamedTempFile::new().unwrap();
let db = Database::create(file.path())?;
let write_txn = db.begin_write()?;
{
let mut table = write_txn.open_table(TABLE)?;
table.insert("my_key", &123)?;
}
write_txn.commit()?;
let read_txn = db.begin_read()?;
let table = read_txn.open_table(TABLE)?;
assert_eq!(table.get("my_key")?.unwrap().value(), 123);
Ok(())
}
Modules§
Structs§
- Access
Guard - Access
Guard Mut - Builder
- Configuration builder of a redb Database.
- Database
- Opened redb database file
- Database
Stats - Informational storage stats about the database
- Drain
- Drain
Filter - Multimap
Range - Multimap
Table - A multimap table
- Multimap
Table Definition - Defines the name and types of a multimap table
- Multimap
Value - Range
- Read
Only Multimap Table - A read-only multimap table
- Read
Only Table - A read-only table
- Read
Only Untyped Multimap Table - A read-only untyped multimap table
- Read
Only Untyped Table - A read-only untyped table
- Read
Transaction - A read-only transaction
- Repair
Session - Savepoint
- Table
- A table containing key-value mappings
- Table
Definition - Defines the name and types of a table
- Table
Stats - Informational storage stats about a table
- Type
Name - Untyped
Multimap Table Handle - Untyped
Table Handle - Write
Transaction - A read/write transaction
Enums§
- Commit
Error - Errors related to committing transactions
- Compaction
Error - Errors related to compaction
- Database
Error - Errors related to opening a database
- Durability
- Error
- Superset of all other errors that can occur. Convenience enum so that users can convert all errors into a single type
- Savepoint
Error - Errors related to savepoints
- Storage
Error - General errors directly from the storage layer
- Table
Error - Errors related to opening tables
- Transaction
Error - Errors related to transactions
Traits§
- Multimap
Table Handle - MutIn
Place Value - Implementing this trait indicates that the type can be mutated in-place as a &mut u8. This enables the .insert_reserve() method on Table
- Readable
Multimap Table - Readable
Table - RedbKey
- Redb
Value - Storage
Backend - Implements persistent storage for a database.
- Table
Handle