pub struct Engine { /* private fields */ }Implementations§
Source§impl Engine
impl Engine
Sourcepub fn spawn_background_maintenance(&self) -> Option<JoinHandle<()>>
pub fn spawn_background_maintenance(&self) -> Option<JoinHandle<()>>
Spawn a background maintenance task that periodically flushes the
memtable to SSTable, runs compaction, and garbage-collects expired
SST files. The task runs until the returned JoinHandle is dropped
or the engine is shut down.
This should be called once after Engine::open when running inside
a Tokio runtime.
pub async fn open(config: Config) -> Result<Self>
pub fn write_batch(&self, batch: &[Record]) -> Result<()>
pub fn write_batch_owned(&self, batch: Vec<Record>) -> Result<()>
pub fn write_batch_sync(&self, batch: Vec<Record>) -> Result<()>
pub fn write_batch_ttl( &self, batch: &[Record], ttl_secs: Option<u64>, ) -> Result<()>
pub async fn query(&self, query: Query) -> Result<Vec<Record>>
pub async fn query_by_prefix(&self, key: &str) -> Result<Vec<Record>>
pub async fn query_by_key_range( &self, start: &str, end: &str, ) -> Result<Vec<Record>>
pub async fn query_time_range( &self, start: i64, end: i64, ) -> Result<Vec<Record>>
pub async fn query_prefix_time_range( &self, key: &str, start: i64, end: i64, ) -> Result<Vec<Record>>
pub async fn query_key_time_range( &self, start_key: &str, end_key: &str, start: i64, end: i64, ) -> Result<Vec<Record>>
pub async fn get(&self, key: &str, ts: i64) -> Result<Option<Record>>
pub fn get_sync(&self, key: &str, ts: i64) -> Option<Record>
pub fn delete_batch(&self, keys_ts: &[(String, i64)]) -> Result<()>
pub fn delete_range(&self, start_key: &str, end_key: &str) -> Result<()>
pub fn patch_record( &self, key: &str, ts: i64, new_value: Option<Vec<u8>>, new_ttl_secs: Option<u64>, ) -> Result<Record>
pub fn stats(&self) -> EngineStats
pub fn metrics_text(&self) -> String
pub async fn flush(&self) -> Result<()>
pub async fn trigger_gc(&self) -> Result<u64>
pub async fn trigger_compaction(&self) -> Result<bool>
Sourcepub async fn shutdown(self) -> Result<()>
pub async fn shutdown(self) -> Result<()>
Shut down the engine, flushing the memtable and WAL. Consumes
self — use Engine::close if the engine is behind an Arc.
Sourcepub async fn close(&self) -> Result<()>
pub async fn close(&self) -> Result<()>
Flush the memtable and WAL without consuming self.
This is the Arc<Engine>-friendly alternative to shutdown. Use
it from server binaries that share the engine across tasks/handlers.
The background maintenance task (if any) is NOT stopped — call
abort() on the handle returned by spawn_background_maintenance
first, or simply drop the JoinHandle.
Sourcepub fn scan(&self, range: ScanRange) -> Result<ScanIterator>
pub fn scan(&self, range: ScanRange) -> Result<ScanIterator>
Lazy iterator scan with default ReadOptions.
Sourcepub fn scan_opt(
&self,
range: ScanRange,
_opts: &ReadOptions,
) -> Result<ScanIterator>
pub fn scan_opt( &self, range: ScanRange, _opts: &ReadOptions, ) -> Result<ScanIterator>
Lazy iterator scan with caller-provided ReadOptions.
Sourcepub fn scan_prefix(&self, prefix: &str) -> Result<ScanIterator>
pub fn scan_prefix(&self, prefix: &str) -> Result<ScanIterator>
Convenience: prefix scan returning a lazy iterator.
Sourcepub fn scan_prefix_time_range(
&self,
prefix: &str,
ts_start: i64,
ts_end: i64,
) -> Result<ScanIterator>
pub fn scan_prefix_time_range( &self, prefix: &str, ts_start: i64, ts_end: i64, ) -> Result<ScanIterator>
Convenience: prefix + time-range scan returning a lazy iterator.