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: usizePage size in bytes (default: 4096)
buffer_pool_pages: usizeBuffer pool size in pages (default: 16384 = 64MB with 4KB pages)
path: PathBufPath to the database file
create_if_missing: boolCreate database if it doesn’t exist
enable_wal: boolEnable WAL for durability
sync_on_commit: boolSync data file on every commit for durability (default: true) Set to false for benchmarks or applications that prioritize speed over durability
encryption: EncryptionConfigEncryption configuration
wal_config: WalGroupCommitConfigWAL group commit configuration
compression: CompressionConfigCompression configuration
eviction_policy: EvictionPolicyTypeBuffer pool eviction policy (default: Clock)
storage_limits: StorageLimitsConfigStorage limits configuration
api_key: Option<String>API key for authentication (v0.3.5)
Implementations§
Source§impl Config
impl Config
pub fn new<P: Into<PathBuf>>(path: P) -> Self
pub fn page_size(self, size: usize) -> Self
pub fn buffer_pool_size_mb(self, mb: usize) -> Self
pub fn create_if_missing(self, create: bool) -> Self
Sourcepub fn with_sync_on_commit(self, sync: bool) -> Self
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.
Sourcepub fn with_password<S: Into<String>>(self, password: S) -> Self
pub fn with_password<S: Into<String>>(self, password: S) -> Self
Enable password-based encryption
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Check if encryption is enabled
Sourcepub fn wal_config(self, config: WalGroupCommitConfig) -> Self
pub fn wal_config(self, config: WalGroupCommitConfig) -> Self
Set WAL configuration for group commit
Sourcepub fn with_group_commit(self) -> Self
pub fn with_group_commit(self) -> Self
Enable group commit mode for improved throughput
Sourcepub fn group_commit_interval_ms(self, ms: u64) -> Self
pub fn group_commit_interval_ms(self, ms: u64) -> Self
Set group commit interval in milliseconds
Sourcepub fn group_commit_max_batch(self, max: usize) -> Self
pub fn group_commit_max_batch(self, max: usize) -> Self
Set maximum batch size for group commit
Sourcepub fn with_compression(self, compression: CompressionConfig) -> Self
pub fn with_compression(self, compression: CompressionConfig) -> Self
Set compression configuration
Sourcepub fn with_lz4_compression(self) -> Self
pub fn with_lz4_compression(self) -> Self
Enable LZ4 compression (fast)
Sourcepub fn with_zstd_compression(self) -> Self
pub fn with_zstd_compression(self) -> Self
Enable ZSTD compression with default level
Sourcepub fn with_zstd_compression_level(self, level: i32) -> Self
pub fn with_zstd_compression_level(self, level: i32) -> Self
Enable ZSTD compression with specified level (1-22)
Sourcepub fn compression_threshold(self, threshold: usize) -> Self
pub fn compression_threshold(self, threshold: usize) -> Self
Set the compression threshold (minimum size to compress)
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
Check if compression is enabled
Sourcepub fn with_eviction_policy(self, policy: EvictionPolicyType) -> Self
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);Sourcepub fn with_lru2_eviction(self) -> Self
pub fn with_lru2_eviction(self) -> Self
Use LRU-2 eviction policy (5-15% higher cache hit rate for mixed workloads)
Sourcepub fn with_lirs_eviction(self) -> Self
pub fn with_lirs_eviction(self) -> Self
Use LIRS eviction policy (best for varying access patterns)
Sourcepub fn with_clock_eviction(self) -> Self
pub fn with_clock_eviction(self) -> Self
Use Clock eviction policy (simple and fast, default)
Sourcepub fn with_storage_limits(self, config: StorageLimitsConfig) -> Self
pub fn with_storage_limits(self, config: StorageLimitsConfig) -> Self
Set storage limits configuration
Sourcepub fn with_max_database_size(self, size: u64) -> Self
pub fn with_max_database_size(self, size: u64) -> Self
Set maximum database file size in bytes
Sourcepub fn with_max_database_size_mb(self, mb: u64) -> Self
pub fn with_max_database_size_mb(self, mb: u64) -> Self
Set maximum database file size in megabytes
Sourcepub fn with_api_key<S: Into<String>>(self, key: S) -> Self
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>.