pub struct LockFreeLog { /* private fields */ }Expand description
lock-free log-structured storage 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);Implementations§
Source§impl LockFreeLog
impl LockFreeLog
Sourcepub fn start_system(config: Config) -> LockFreeLog
pub fn start_system(config: Config) -> LockFreeLog
create new lock-free log
Trait Implementations§
Source§impl Drop for LockFreeLog
impl Drop for LockFreeLog
Source§impl Log for LockFreeLog
impl Log for LockFreeLog
Source§fn stable_offset(&self) -> u64
fn stable_offset(&self) -> u64
returns the current stable offset written to disk
Source§fn make_stable(&self, id: u64)
fn make_stable(&self, id: u64)
blocks until the specified id has been made stable on disk
Source§fn punch_hole(&self, id: u64)
fn punch_hole(&self, id: u64)
deallocates the data part of a log id
impl Send for LockFreeLog
impl Sync for LockFreeLog
Auto Trait Implementations§
impl Freeze for LockFreeLog
impl !RefUnwindSafe for LockFreeLog
impl Unpin for LockFreeLog
impl !UnwindSafe for LockFreeLog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more