Skip to main content

Crate walcraft

Crate walcraft 

Source
Expand description

A Write Ahead Log (WAL) solution for concurrent environments

§How?

This library provides high performance by using an in-memory buffer and append-only logs. The logs are stored in multiple files, and older files are deleted to save space.

§Usage

use serde::{Deserialize, Serialize};
use walcraft::Wal;

// Log to write
#[derive(Serialize, Deserialize, Debug)]
struct Log {
    id: usize,
    value: f64
}

// create an instance of WAL
let wal = Wal::new("/tmp/walcraft", Some(2000)).unwrap();

// recovery: Option A
let all_logs = wal.iter().unwrap().collect::<Vec<_>>();
// recovery: Option B
for log in wal.iter().unwrap() {
  // do something with logs
  dbg!(log.data());
}

// start writing
wal.append(b"LOG_START").unwrap();
wal.append_struct(Log{id: 1, value: 3.14}).unwrap();
wal.append_struct(Log{id: 2, value: 4.20}).unwrap();

// Flush to disk early/manually, before the page is filled
wal.flush().unwrap();

Structs§

LogEntry
A log entry in the Write Ahead Log (WAL). This struct wraps a byte vector and provides methods to access the data
Wal
Write Ahead Log (WAL)
WalBuilder
Build Wal with custom configuration
WalIterator
An iterator over the log entries in the Write Ahead Log (WAL).

Enums§

Size
Represents the size of data in KBs, MBs or GBs, such as
WalError
Error handling module for the Write Ahead Log (WAL) implementation

Constants§

IDEAL_NUM_FILES
MAX_STORAGE
MIN_SIZE_PER_FILE
PAGE_MULTIPLIER
TESTING_DIR
WAL_VERSION