Skip to content

Configuration

Redlite operates with default settings that can be overridden via command-line arguments or API calls.

ArgumentShortDefaultDescription
--db-dredlite.dbDatabase file path
--addr-a127.0.0.1:6379Listen address and port
--password(none)Require password for connections (like Redis requirepass)
--storagefileStorage type: file or memory
--cache64SQLite page cache size in MB (larger = faster reads)
--max-memory0Maximum memory size in bytes (0 = unlimited). Evicts keys based on policy
--max-disk0Maximum disk size in bytes (0 = unlimited). Evicts oldest keys when exceeded
--eviction-policynoevictionMemory eviction policy: noeviction, allkeys-lru, allkeys-lfu, allkeys-random, volatile-lru, volatile-lfu, volatile-ttl, volatile-random
Terminal window
# Persistent file
./redlite --db /var/lib/redlite/data.db
# In-memory (no persistence)
./redlite --storage memory
Terminal window
# 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:6380
Terminal window
# Require password for all connections
./redlite --db mydata.db --password secret
Terminal window
# Use 1GB cache for high-performance reads
./redlite --db mydata.db --cache 1024
# Default: 64MB cache
./redlite --db mydata.db

The --cache flag sets SQLite’s page cache size. Larger values keep more data in RAM for faster reads while maintaining full durability.

Terminal window
# 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-lfu

When --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 keys
  • allkeys-lfu - Evict least frequently used keys
  • allkeys-random - Evict random keys
  • volatile-lru - Evict least recently used keys with TTL
  • volatile-lfu - Evict least frequently used keys with TTL
  • volatile-ttl - Evict keys closest to expiration
  • volatile-random - Evict random keys with TTL

Runtime adjustment:

Terminal window
# Via redis-cli or any Redis client
CONFIG SET maxmemory 52428800 # Change to 50MB
CONFIG SET maxmemory-policy allkeys-lfu # Switch to LFU
CONFIG GET maxmemory # Check current limit

See Eviction for detailed documentation.

Terminal window
# Limit database to 100MB on disk
./redlite --db mydata.db --max-disk 104857600

When --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:

Terminal window
# Via redis-cli or any Redis client
CONFIG SET maxdisk 52428800 # Change to 50MB
CONFIG GET maxdisk # Check current limit

When using Redlite as an embedded library, configuration is done through code:

use redlite::Db;
// Persistent database
let db = Db::open("/path/to/data.db")?;
// In-memory database
let db = Db::open_memory()?;
// With custom cache size (1GB)
let db = Db::open_with_cache("/path/to/data.db", 1024)?;
// Or set cache at runtime
let 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 eviction
use redlite::EvictionPolicy;
db.set_max_memory(100 * 1024 * 1024)?; // 100MB limit
db.set_eviction_policy(EvictionPolicy::AllKeysLru);
// Configure access tracking persistence
db.set_persist_access_tracking(true); // Persist LRU/LFU data to SQLite
db.set_access_flush_interval(5000); // Flush every 5 seconds

Redlite configures SQLite with these defaults:

SettingValuePurpose
journal_modeWALWrite-ahead logging for concurrent readers
synchronousNORMALFsync at checkpoints, not every commit
foreign_keysONEnforce foreign key constraints
busy_timeout5000msWait duration for locked database

These settings are applied automatically when opening a database and cannot currently be changed.

Currently, Redlite does not use environment variables. All configuration is done via command line arguments or programmatically.

Redlite uses the tracing crate for logging. Configure with standard Rust logging environment variables:

Terminal window
# Enable info logging
RUST_LOG=info ./redlite --db mydata.db
# Debug logging
RUST_LOG=debug ./redlite --db mydata.db
# Trace logging (very verbose)
RUST_LOG=trace ./redlite --db mydata.db
LimitValue
Max databases16 (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.