sync_engine/eviction/
mod.rs

1//! Eviction policies for tiered cache management.
2//!
3//! This module contains eviction logic for both L1 (in-memory) and L2 (Redis)
4//! caches, using a consistent tan-curve scoring algorithm.
5//!
6//! # Architecture
7//!
8//! ```text
9//! ┌──────────────────────────────────────────────────────────────┐
10//! │                    Eviction Module                           │
11//! ├──────────────────────────────────────────────────────────────┤
12//! │  tan_curve.rs   - Core scoring algorithm                     │
13//! │  └─ TanCurveMemoryPressure: pressure → multiplier            │
14//! │  └─ TanCurvePolicy: recency + frequency + size → score       │
15//! │  └─ CacheEntry: generic entry metadata for scoring           │
16//! ├──────────────────────────────────────────────────────────────┤
17//! │  redis.rs       - Redis-specific eviction                    │
18//! │  └─ RedisEvictionManager: proactive eviction before LRU      │
19//! │  └─ RedisMemoryProfile: cached INFO MEMORY to avoid RTT      │
20//! │  └─ Protected prefixes: merkle:*, idx:*                      │
21//! └──────────────────────────────────────────────────────────────┘
22//! ```
23//!
24//! # L1 Memory Eviction
25//!
26//! L1 eviction is handled directly in `coordinator/mod.rs` using `TanCurvePolicy`.
27//! The coordinator builds `CacheEntry` from `SyncItem` and calls `select_victims()`.
28//!
29//! # L2 Redis Eviction
30//!
31//! Redis eviction is proactive - we evict before Redis LRU kicks in to protect
32//! infrastructure keys (merkle trees, RediSearch indexes). The `RedisEvictionManager`
33//! tracks key metadata and uses `TanCurvePolicy` for consistent scoring.
34
35pub mod tan_curve;
36pub mod redis;