Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub page_size: usize,
    pub buffer_pool_pages: usize,
    pub path: PathBuf,
    pub create_if_missing: bool,
    pub enable_wal: bool,
    pub sync_on_commit: bool,
    pub encryption: EncryptionConfig,
    pub wal_config: WalGroupCommitConfig,
    pub compression: CompressionConfig,
    pub eviction_policy: EvictionPolicyType,
    pub storage_limits: StorageLimitsConfig,
    pub api_key: Option<String>,
}
Expand description

Database configuration options

Fields§

§page_size: usize

Page size in bytes (default: 4096)

§buffer_pool_pages: usize

Buffer pool size in pages (default: 16384 = 64MB with 4KB pages)

§path: PathBuf

Path to the database file

§create_if_missing: bool

Create database if it doesn’t exist

§enable_wal: bool

Enable WAL for durability

§sync_on_commit: bool

Sync data file on every commit for durability (default: true) Set to false for benchmarks or applications that prioritize speed over durability

§encryption: EncryptionConfig

Encryption configuration

§wal_config: WalGroupCommitConfig

WAL group commit configuration

§compression: CompressionConfig

Compression configuration

§eviction_policy: EvictionPolicyType

Buffer pool eviction policy (default: Clock)

§storage_limits: StorageLimitsConfig

Storage limits configuration

§api_key: Option<String>

API key for authentication (v0.3.5)

Implementations§

Source§

impl Config

Source

pub fn new<P: Into<PathBuf>>(path: P) -> Self

Source

pub fn page_size(self, size: usize) -> Self

Source

pub fn buffer_pool_size_mb(self, mb: usize) -> Self

Source

pub fn create_if_missing(self, create: bool) -> Self

Source

pub fn with_sync_on_commit(self, sync: bool) -> Self

Set whether to sync the data file on every commit (default: true)

When false, committed data may be lost on crash but write operations are significantly faster. Useful for benchmarks and non-critical data.

Source

pub fn with_password<S: Into<String>>(self, password: S) -> Self

Enable password-based encryption

Source

pub fn with_key(self, key: [u8; 32]) -> Self

Enable encryption with a raw key

Source

pub fn is_encrypted(&self) -> bool

Check if encryption is enabled

Source

pub fn wal_config(self, config: WalGroupCommitConfig) -> Self

Set WAL configuration for group commit

Source

pub fn with_group_commit(self) -> Self

Enable group commit mode for improved throughput

Source

pub fn group_commit_interval_ms(self, ms: u64) -> Self

Set group commit interval in milliseconds

Source

pub fn group_commit_max_batch(self, max: usize) -> Self

Set maximum batch size for group commit

Source

pub fn with_compression(self, compression: CompressionConfig) -> Self

Set compression configuration

Source

pub fn with_lz4_compression(self) -> Self

Enable LZ4 compression (fast)

Source

pub fn with_zstd_compression(self) -> Self

Enable ZSTD compression with default level

Source

pub fn with_zstd_compression_level(self, level: i32) -> Self

Enable ZSTD compression with specified level (1-22)

Source

pub fn compression_threshold(self, threshold: usize) -> Self

Set the compression threshold (minimum size to compress)

Source

pub fn is_compressed(&self) -> bool

Check if compression is enabled

Source

pub fn with_eviction_policy(self, policy: EvictionPolicyType) -> Self

Set the buffer pool eviction policy

§Example
use featherdb_core::{Config, EvictionPolicyType};

let config = Config::new("mydb.db")
    .with_eviction_policy(EvictionPolicyType::Lru2);
Source

pub fn with_lru2_eviction(self) -> Self

Use LRU-2 eviction policy (5-15% higher cache hit rate for mixed workloads)

Source

pub fn with_lirs_eviction(self) -> Self

Use LIRS eviction policy (best for varying access patterns)

Source

pub fn with_clock_eviction(self) -> Self

Use Clock eviction policy (simple and fast, default)

Source

pub fn with_storage_limits(self, config: StorageLimitsConfig) -> Self

Set storage limits configuration

Source

pub fn with_max_database_size(self, size: u64) -> Self

Set maximum database file size in bytes

Source

pub fn with_max_database_size_mb(self, mb: u64) -> Self

Set maximum database file size in megabytes

Source

pub fn with_api_key<S: Into<String>>(self, key: S) -> Self

Set the API key for authentication

If the database requires authentication, provide the API key here. Keys are in the format fdb_<base64>.

Source

pub fn validate(&self) -> Result<(), ConfigError>

Validate the database configuration

§Validation Rules
  • page_size: must be a power of 2 between 512 bytes and 64KB
  • buffer_pool_pages: must be at least 16 pages
  • wal_config: must pass validation
  • compression: must pass validation
§Errors

Returns ConfigError if validation fails

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.