Struct rsdb::LockFreeLog [] [src]

pub struct LockFreeLog { /* fields omitted */ }

A sequential store which allows users to create reservations placed at known log offsets, used for writing persistent data structures that need to know where to find persisted bits in the future.

Working with LockFreeLog

use rsdb::Log;

let log = rsdb::Config::default().log();
let first_offset = log.write(b"1".to_vec());
log.write(b"22".to_vec());
log.write(b"333".to_vec());

// stick an abort in the middle, which should not be returned
let res = log.reserve(b"never_gonna_hit_disk".to_vec());
res.abort();

log.write(b"4444".to_vec());
let last_offset = log.write(b"55555".to_vec());
log.make_stable(last_offset);
let mut iter = log.iter_from(first_offset);
assert_eq!(iter.next().unwrap().1, b"1".to_vec());
assert_eq!(iter.next().unwrap().1, b"22".to_vec());
assert_eq!(iter.next().unwrap().1, b"333".to_vec());
assert_eq!(iter.next().unwrap().1, b"4444".to_vec());
assert_eq!(iter.next().unwrap().1, b"55555".to_vec());
assert_eq!(iter.next(), None);

Methods

impl LockFreeLog
[src]

create new lock-free log

Flush the next io buffer.

Trait Implementations

impl Send for LockFreeLog
[src]

impl Sync for LockFreeLog
[src]

impl Drop for LockFreeLog
[src]

A method called when the value goes out of scope. Read more

impl Log for LockFreeLog
[src]

Create a log offset reservation for a particular write, which may later be filled or canceled. Read more

return the config in use for this log

Write a buffer to underlying storage.

read a buffer from the disk

returns the current stable offset written to disk

blocks until the specified id has been made stable on disk

deallocates the data part of a log id

Return an iterator over the log, starting with a specified offset. Read more