pub struct StoreBuilder { /* private fields */ }
Expand description
Builder for creating FeoxStore with custom configuration.
Provides a fluent interface for configuring store parameters.
§Example
use feoxdb::FeoxStore;
let store = FeoxStore::builder()
.max_memory(1_000_000_000)
.hash_bits(20)
.enable_ttl(true)
.build()?;
Implementations§
Source§impl StoreBuilder
impl StoreBuilder
pub fn new() -> Self
Sourcepub fn device_path(self, path: impl Into<String>) -> Self
pub fn device_path(self, path: impl Into<String>) -> Self
Set the device path for persistent storage.
When set, data will be persisted to disk asynchronously. If not set, the store operates in memory-only mode.
Sourcepub fn file_size(self, size: u64) -> Self
pub fn file_size(self, size: u64) -> Self
Set the initial file size for new persistent stores (in bytes).
When creating a new persistent store file, it will be pre-allocated to this size for better performance. If not set, defaults to 1GB. This option is ignored for existing files.
§Example
use feoxdb::FeoxStore;
let store = FeoxStore::builder()
.device_path("/path/to/data.feox")
.file_size(10 * 1024 * 1024 * 1024) // 10GB
.build()?;
Sourcepub fn max_memory(self, limit: usize) -> Self
pub fn max_memory(self, limit: usize) -> Self
Set the maximum memory limit (in bytes).
The store will start evicting entries when this limit is approached. Default: 1GB
Sourcepub fn no_memory_limit(self) -> Self
pub fn no_memory_limit(self) -> Self
Remove memory limit.
Use with caution as the store can grow unbounded.
Sourcepub fn hash_bits(self, bits: u32) -> Self
pub fn hash_bits(self, bits: u32) -> Self
Set number of hash bits (determines hash table size).
More bits = larger hash table = better performance for large datasets. Default: 18 (256K buckets)
Sourcepub fn enable_caching(self, enable: bool) -> Self
pub fn enable_caching(self, enable: bool) -> Self
Enable or disable caching.
When enabled, frequently accessed values are kept in memory even after being written to disk. Uses CLOCK eviction algorithm.
Sourcepub fn enable_ttl(self, enable: bool) -> Self
pub fn enable_ttl(self, enable: bool) -> Self
Enable or disable TTL (Time-To-Live) functionality.
When disabled (default), TTL operations will return errors and no background cleaner runs. When enabled, keys can have expiry times and a background cleaner removes expired keys. Default: false (disabled for optimal performance)
Sourcepub fn enable_ttl_cleaner(self, enable: bool) -> Self
pub fn enable_ttl_cleaner(self, enable: bool) -> Self
Enable or disable TTL sweeper.
When enabled, a background thread periodically removes expired keys. Note: This method is deprecated in favor of enable_ttl().
Sourcepub fn ttl_sweeper_config(
self,
sample_size: usize,
threshold: f32,
max_time_ms: u64,
interval_ms: u64,
) -> Self
pub fn ttl_sweeper_config( self, sample_size: usize, threshold: f32, max_time_ms: u64, interval_ms: u64, ) -> Self
Configure TTL sweeper with custom parameters.
§Arguments
sample_size
- Keys to check per batchthreshold
- Continue if >threshold expired (0.0-1.0)max_time_ms
- Max milliseconds per cleaning runinterval_ms
- Sleep between runs