CacheKit Docs

High-performance cache policies and supporting data structures.

View the Project on GitHub OxidizeLabs/cachekit

CLOCK-Pro

Feature: policy-clock-pro

Goal

Improve Clock’s scan behavior by tracking hot/cold classification and ghost entries using Clock-style hands.

Core Idea

Maintain three conceptual groups:

Clock hands circulate and adjust status; sequential scans churn through cold pages rather than evicting hot pages.

Core Data Structures

Implementation uses:

Operations

Scan Resistance

Clock-PRO resists scan pollution because:

  1. New inserts start as cold (sequential scans only touch cold pages)
  2. Cold pages need a second access to become hot
  3. Hot pages are protected from eviction
  4. Ghost hits boost re-accessed keys directly to hot status

Complexity & Overhead

Operation Time Notes
get O(1) Hash lookup + bit operation
insert O(1)* *Amortized; eviction may sweep
contains O(1) Hash lookup only
remove O(1) Hash lookup + clear slot

Thread Safety

References