pub struct DualCacheFF<K, V, S = RandomState> {
pub hasher: S,
pub t1: Arc<T1<K, V>>,
pub t2: Arc<T2<K, V>>,
pub cache: Arc<Cache<K, V>>,
pub cmd_tx: Arc<LossyQueue<Command<K, V>>>,
pub hit_tx: Arc<LossyQueue<[usize; 64]>>,
pub epoch: Arc<AtomicU32>,
pub worker_states: Arc<[WorkerState]>,
pub miss_buffers: Arc<[WorkerSlot<K, V>]>,
pub daemon_tick: Arc<AtomicU64>,
pub flush_tick_threshold: u64,
}Fields§
§hasher: S§t1: Arc<T1<K, V>>§t2: Arc<T2<K, V>>§cache: Arc<Cache<K, V>>§cmd_tx: Arc<LossyQueue<Command<K, V>>>§hit_tx: Arc<LossyQueue<[usize; 64]>>§epoch: Arc<AtomicU32>§worker_states: Arc<[WorkerState]>QSBR registry: one entry per thread slot.
miss_buffers: Arc<[WorkerSlot<K, V>]>Per-worker zero-lock batch buffers, indexed by WORKER_ID.
daemon_tick: Arc<AtomicU64>Daemon tick counter — shared with the Daemon thread. Workers read this (Relaxed) to implement time-based TLS flush.
flush_tick_threshold: u64Number of daemon_tick advances that correspond to ≈1 ms of real time.
Implementations§
Source§impl<K, V> DualCacheFF<K, V, RandomState>
impl<K, V> DualCacheFF<K, V, RandomState>
Source§impl<K, V> DualCacheFF<K, V, RandomState>
impl<K, V> DualCacheFF<K, V, RandomState>
Sourcepub fn new_headless(config: Config) -> (Self, Daemon<K, V, RandomState>)
pub fn new_headless(config: Config) -> (Self, Daemon<K, V, RandomState>)
Create a DualCacheFF and its Daemon without spawning any thread.
§std mode
Prefer DualCacheFF::new() which spawns the daemon automatically.
§no_std / RTOS mode
Use new_headless() to obtain both the cache handle and the daemon.
Schedule daemon.run() on a dedicated RTOS task:
let (cache, daemon) = DualCacheFF::new_headless(config);
rtos::spawn_task(|| daemon.run()); // RTOS-specific APISource§impl<K, V, S> DualCacheFF<K, V, S>
impl<K, V, S> DualCacheFF<K, V, S>
Sourcepub fn sync(&self)
pub fn sync(&self)
Flush all pending TLS buffers and wait for the Daemon to process them.
Blocks via OneshotAck::wait() (spin-wait, safe in both std and no_std).
Sourcepub fn get(&self, key: &K) -> Option<V>
pub fn get(&self, key: &K) -> Option<V>
Look up a key.
Hot-path order: T1 (L1 direct-map) → T2 (L2 direct-map) → Cache (L3). Records a hit signal into the TLS buffer for Daemon processing.
Sourcepub fn insert(&self, key: K, value: V)
pub fn insert(&self, key: K, value: V)
Insert a key-value pair.
§L1 Probation Filter (std only)
Items that appear only once in a TLS epoch are silently dropped. This prevents cache pollution from scan traffic. In no_std mode the filter is skipped and all items are forwarded.
§Task 6 — Time-based TLS Flush (std only)
The TLS batch buffer normally flushes when it reaches 32 items.
Additionally, if the Daemon tick counter has advanced by at least
flush_tick_threshold since the last flush, the buffer is force-drained
even if nearly empty. This prevents hot items from being invisible to
the Daemon for too long (the “split-brain eviction” bug).