rat_memcache 0.2.2

高性能 Memcached 协议兼容服务器,支持双层缓存和持久化存储
Documentation
# RatMemcache 缓存配置文件
# Surface Book 2 优化配置

[l1]
# L1 缓存配置(内存缓存)
max_memory = 1073741824  # 1GB (Surface Book 2优化)
max_entries = 100000
eviction_strategy = "Lru"

[l2]
# L2 缓存配置(MelangeDB持久化存储)
enable_l2_cache = true
data_dir = "./rat_memcache_data"
clear_on_startup = false
max_disk_size = 1073741824  # 1GB (Surface Book 2优化)
write_buffer_size = 67108864  # 64MB
max_write_buffer_number = 3
block_cache_size = 33554432  # 32MB
background_threads = 4
enable_lz4 = true
compression_threshold = 128  # 128 bytes
compression_max_threshold = 1048576  # 1MB
compression_level = 6

# MelangeDB配置 (Surface Book 2优化)
compression_algorithm = "Lz4"
cache_size_mb = 512
max_file_size_mb = 1024
enable_statistics = true
cache_warmup_strategy = "Recent"

# 智能flush配置 (Surface Book 2 优化)
smart_flush_enabled = true
smart_flush_base_interval_ms = 100      # 100ms基础间隔,SSD优化
smart_flush_min_interval_ms = 20       # 20ms最小间隔,低延迟
smart_flush_max_interval_ms = 500      # 500ms最大间隔,平衡延迟
smart_flush_write_rate_threshold = 8000   # 8K ops/sec阈值,稳定高负载检测
smart_flush_accumulated_bytes_threshold = 8388608  # 8MB累积字节,最佳平衡点

# ZSTD压缩级别 (如果使用ZSTD压缩时生效)
# zstd_compression_level = 6

[ttl]
# TTL 配置
default_ttl = 3600  # 1小时
max_ttl = 86400     # 24小时
cleanup_interval = 300  # 5分钟
max_cleanup_entries = 1000
lazy_expiration = true
active_expiration = true

[performance]
# 性能配置
worker_threads = 4
enable_concurrency = true
read_write_separation = true
batch_size = 100
enable_warmup = true
stats_interval = 60
enable_background_stats = true
l2_write_strategy = "WriteThrough"
l2_write_threshold = 1024
large_value_threshold = 10240  # 10KB 大值阈值
l2_write_ttl_threshold = 3600

[logging]
# 日志配置
level = "DEBUG"
enable_colors = true
show_timestamp = true
enable_performance_logs = true
enable_audit_logs = true
enable_cache_logs = true

# === 新的高级日志配置 ===
# 是否完全禁用日志系统(设置为false可获得最高性能)
enable_logging = true

# 是否启用异步模式(异步模式可提高性能,但可能在程序崩溃时丢失日志)
enable_async = false

# 异步模式的批量配置(仅在enable_async=true时生效)
batch_size = 2048        # 2KB
batch_interval_ms = 25  # 25ms
buffer_size = 16384     # 16KB