▮ RECOMMENDED USE
Tied top local scorer (82). The only local model to use delta-based transactional frequency accounting (freq bumps deferred to commit), matching the cloud baseline's isolation approach. Reliable for async/ACID-pattern work after a __slots__ + min_freq-edge pass.
▮ REFACTORED PATCH
# FIX 1 (stale min_freq): recompute or invalidate when the min bucket empties.
# In _remove_node_from_structures, replace the `pass`:
if dll.size == 0:
del self.freq_map[node.freq]
if self.min_freq == node.freq:
# bump to next existing tier (frequencies are contiguous under normal use)
self.min_freq = self.min_freq + 1 if (self.min_freq + 1) in self.freq_map else min(self.freq_map, default=1)
# FIX 2: add __slots__ to Node, DoublyLinkedList, LFUCache, Transaction.
# FIX 3: background evictor — maintain a _ttl_keys set and iterate IT in
# batches instead of list(self.cache_data.keys()) to stay O(batch).
# FIX 4: wrap commit's three loops in try/except with rollback semantics on failure.