pub struct TurboPersistence { /* private fields */ }
Expand description
TurboPersistence is a persistent key-value store. It is limited to a single writer at a time using a single write batch. It allows for concurrent reads.
Implementations§
Source§impl TurboPersistence
impl TurboPersistence
Sourcepub fn open(path: PathBuf) -> Result<Self>
pub fn open(path: PathBuf) -> Result<Self>
Open a TurboPersistence database at the given path. This will read the directory and might performance cleanup when the database was not closed properly. Cleanup only requires to read a few bytes from a few files and to delete files, so it’s fast.
Sourcepub fn open_read_only(path: PathBuf) -> Result<Self>
pub fn open_read_only(path: PathBuf) -> Result<Self>
Open a TurboPersistence database at the given path in read only mode. This will read the directory. No Cleanup is performed.
Sourcepub fn write_batch<K: StoreKey + Send + Sync + 'static, const FAMILIES: usize>(
&self,
) -> Result<WriteBatch<K, FAMILIES>>
pub fn write_batch<K: StoreKey + Send + Sync + 'static, const FAMILIES: usize>( &self, ) -> Result<WriteBatch<K, FAMILIES>>
Starts a new WriteBatch for the database. Only a single write operation is allowed at a
time. The WriteBatch need to be committed with TurboPersistence::commit_write_batch
.
Note that the WriteBatch might start writing data to disk while it’s filled up with data.
This data will only become visible after the WriteBatch is committed.
Sourcepub fn commit_write_batch<K: StoreKey + Send + Sync + 'static, const FAMILIES: usize>(
&self,
write_batch: WriteBatch<K, FAMILIES>,
) -> Result<()>
pub fn commit_write_batch<K: StoreKey + Send + Sync + 'static, const FAMILIES: usize>( &self, write_batch: WriteBatch<K, FAMILIES>, ) -> Result<()>
Commits a WriteBatch to the database. This will finish writing the data to disk and make it visible to readers.
Sourcepub fn full_compact(&self) -> Result<()>
pub fn full_compact(&self) -> Result<()>
Runs a full compaction on the database. This will rewrite all SST files, removing all duplicate keys and separating all key ranges into unique files.
Sourcepub fn compact(&self, compact_config: &CompactConfig) -> Result<()>
pub fn compact(&self, compact_config: &CompactConfig) -> Result<()>
Runs a (partial) compaction. Compaction will only be performed if the coverage of the SST files is above the given threshold. The coverage is the average number of SST files that need to be read to find a key. It also limits the maximum number of SST files that are merged at once, which is the main factor for the runtime of the compaction.
Sourcepub fn get<K: QueryKey>(
&self,
family: usize,
key: &K,
) -> Result<Option<ArcSlice<u8>>>
pub fn get<K: QueryKey>( &self, family: usize, key: &K, ) -> Result<Option<ArcSlice<u8>>>
Get a value from the database. Returns None if the key is not found. The returned value might hold onto a block of the database and it should not be hold long-term.
pub fn meta_info(&self) -> Result<Vec<MetaFileInfo>>
Auto Trait Implementations§
impl !Freeze for TurboPersistence
impl !RefUnwindSafe for TurboPersistence
impl Send for TurboPersistence
impl Sync for TurboPersistence
impl Unpin for TurboPersistence
impl !UnwindSafe for TurboPersistence
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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