Configuration
Redlite operates with default settings that can be overridden via command-line arguments or API calls.
Server Configuration
Section titled âServer ConfigurationâCommand Line Arguments
Section titled âCommand Line Argumentsâ| Argument | Short | Default | Description |
|---|---|---|---|
--db | -d | redlite.db | Database file path |
--addr | -a | 127.0.0.1:6379 | Listen address and port |
--password | (none) | Require password for connections (like Redis requirepass) | |
--storage | file | Storage type: file or memory | |
--cache | 64 | SQLite page cache size in MB (larger = faster reads) | |
--max-memory | 0 | Maximum memory size in bytes (0 = unlimited). Evicts keys based on policy | |
--max-disk | 0 | Maximum disk size in bytes (0 = unlimited). Evicts oldest keys when exceeded | |
--eviction-policy | noeviction | Memory eviction policy: noeviction, allkeys-lru, allkeys-lfu, allkeys-random, volatile-lru, volatile-lfu, volatile-ttl, volatile-random |
Database Path
Section titled âDatabase Pathâ# Persistent file./redlite --db /var/lib/redlite/data.db
# In-memory (no persistence)./redlite --storage memoryNetwork Binding
Section titled âNetwork Bindingâ# Localhost only (default)./redlite --addr 127.0.0.1:6379
# All interfaces./redlite --addr 0.0.0.0:6379
# Custom port./redlite --addr 127.0.0.1:6380Authentication
Section titled âAuthenticationâ# Require password for all connections./redlite --db mydata.db --password secretPerformance Tuning
Section titled âPerformance Tuningâ# Use 1GB cache for high-performance reads./redlite --db mydata.db --cache 1024
# Default: 64MB cache./redlite --db mydata.dbThe --cache flag sets SQLiteâs page cache size. Larger values keep more data in RAM for faster reads while maintaining full durability.
Memory Eviction
Section titled âMemory Evictionâ# Limit to 100MB with LRU eviction./redlite --db mydata.db --max-memory 104857600 --eviction-policy allkeys-lru
# LFU policy for frequency-based eviction./redlite --db mydata.db --max-memory 104857600 --eviction-policy allkeys-lfuWhen --max-memory is set, redlite tracks access patterns and evicts keys based on the configured policy. The eviction process uses a vacuum-first strategy: expired keys are removed before evicting valid keys.
Available policies:
noeviction- Return errors when memory limit is reached (default)allkeys-lru- Evict least recently used keysallkeys-lfu- Evict least frequently used keysallkeys-random- Evict random keysvolatile-lru- Evict least recently used keys with TTLvolatile-lfu- Evict least frequently used keys with TTLvolatile-ttl- Evict keys closest to expirationvolatile-random- Evict random keys with TTL
Runtime adjustment:
# Via redis-cli or any Redis clientCONFIG SET maxmemory 52428800 # Change to 50MBCONFIG SET maxmemory-policy allkeys-lfu # Switch to LFUCONFIG GET maxmemory # Check current limitSee Eviction for detailed documentation.
Disk Eviction
Section titled âDisk Evictionâ# Limit database to 100MB on disk./redlite --db mydata.db --max-disk 104857600When --max-disk is set, redlite automatically evicts the oldest keys (by creation time) when disk usage exceeds the limit. Eviction checks run every second during write operations.
Runtime adjustment:
# Via redis-cli or any Redis clientCONFIG SET maxdisk 52428800 # Change to 50MBCONFIG GET maxdisk # Check current limitLibrary Configuration
Section titled âLibrary ConfigurationâWhen using Redlite as an embedded library, configuration is done through code:
use redlite::Db;
// Persistent databaselet db = Db::open("/path/to/data.db")?;
// In-memory databaselet db = Db::open_memory()?;
// With custom cache size (1GB)let db = Db::open_with_cache("/path/to/data.db", 1024)?;
// Or set cache at runtimelet db = Db::open("/path/to/data.db")?;db.set_cache_mb(1024)?;
// Select database (0-15)let mut db = Db::open("/path/to/data.db")?;db.select(1)?;
// Configure memory evictionuse redlite::EvictionPolicy;db.set_max_memory(100 * 1024 * 1024)?; // 100MB limitdb.set_eviction_policy(EvictionPolicy::AllKeysLru);
// Configure access tracking persistencedb.set_persist_access_tracking(true); // Persist LRU/LFU data to SQLitedb.set_access_flush_interval(5000); // Flush every 5 secondsSQLite Settings
Section titled âSQLite SettingsâRedlite configures SQLite with these defaults:
| Setting | Value | Purpose |
|---|---|---|
journal_mode | WAL | Write-ahead logging for concurrent readers |
synchronous | NORMAL | Fsync at checkpoints, not every commit |
foreign_keys | ON | Enforce foreign key constraints |
busy_timeout | 5000ms | Wait duration for locked database |
These settings are applied automatically when opening a database and cannot currently be changed.
Environment Variables
Section titled âEnvironment VariablesâCurrently, Redlite does not use environment variables. All configuration is done via command line arguments or programmatically.
Logging
Section titled âLoggingâRedlite uses the tracing crate for logging. Configure with standard Rust logging environment variables:
# Enable info loggingRUST_LOG=info ./redlite --db mydata.db
# Debug loggingRUST_LOG=debug ./redlite --db mydata.db
# Trace logging (very verbose)RUST_LOG=trace ./redlite --db mydata.dbDatabase Limits
Section titled âDatabase Limitsâ| Limit | Value |
|---|---|
| Max databases | 16 (0-15) |
| Max key size | ~1GB (SQLite blob limit) |
| Max value size | ~1GB (SQLite blob limit) |
| Max database size | ~281TB (SQLite limit) |
In practice, youâll hit disk space limits long before SQLite limits.