Skip to content

Configuration

SlateDB configuration shows up in three main places:

  1. Settings holds serializable runtime settings.
  2. Builders such as DbBuilder and DbReaderBuilder have with_* functions to handle complex types and dependency injection.
  3. Operation-specific option types such as ReadOptions and WriteOptions.

For the complete configuration surface and current defaults, read the slatedb::config rustdoc.

This example shows all three configuration layers in one place:

use slatedb::{
config::{DbReaderOptions, ReadOptions, Settings},
db_cache::foyer::FoyerCache,
object_store::{memory::InMemory, ObjectStore},
Db, DbReader, Error,
};
use std::sync::Arc;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Error> {
let object_store: Arc<dyn ObjectStore> = Arc::new(InMemory::new());
// 1. Serializable runtime settings.
let mut settings = Settings::default();
settings.flush_interval = Some(Duration::from_millis(250));
// 2. Builder configuration for process-local components and wiring.
let db = Db::builder("example", Arc::clone(&object_store))
.with_settings(settings)
.with_db_cache(Arc::new(FoyerCache::new()))
.build()
.await?;
// 3. Per-call options for one operation.
let _value = db
.get_with_options(
b"key",
&ReadOptions::default().with_cache_blocks(false),
)
.await?;
// Reader-specific options configure the DbReader instance itself.
let mut reader_options = DbReaderOptions::default();
reader_options.skip_wal_replay = true;
let _reader = DbReader::builder("example", object_store)
.with_options(reader_options)
.build()
.await?;
Ok(())
}