[workspace]
members = [".", "bench-support"]
resolver = "2"

[package]
name = "cachekit"
version = "0.6.0"
edition = "2024"
rust-version = "1.85"
authors = ["Thomas Korrison <ferrite.db@gmail.com>"]
license = "MIT OR Apache-2.0"
description = "High-performance cache primitives with pluggable eviction policies (LRU, LFU, FIFO, 2Q, Clock-PRO, S3-FIFO) and optional metrics."
homepage = "https://oxidizelabs.github.io/cachekit/"
repository = "https://github.com/OxidizeLabs/cachekit"
readme = "README.md"
keywords = ["cache", "lru", "lfu", "eviction", "s3-fifo"]
categories = ["caching", "data-structures"]
exclude = ["/.idea/", "/.DS_Store", "/**/.DS_Store"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
targets = ["x86_64-unknown-linux-gnu"]

[lib]
name = "cachekit"
path = "src/lib.rs"
test = true
doctest = true
bench = true
doc = true
crate-type = ["lib"]

[features]
default = ["policy-s3-fifo", "policy-lru", "policy-fast-lru", "policy-lru-k", "policy-clock"]
metrics = []
serde = ["dep:serde"]
concurrency = ["parking_lot"]

# Eviction policy feature flags. Enable only the policies you need for smaller builds.
# Use `default-features = false` and select specific policies, or use `policy-all` for every policy.
policy-all = [
    "policy-fifo",
    "policy-lru",
    "policy-fast-lru",
    "policy-lru-k",
    "policy-lfu",
    "policy-heap-lfu",
    "policy-two-q",
    "policy-s3-fifo",
    "policy-arc",
    "policy-car",
    "policy-lifo",
    "policy-mfu",
    "policy-mru",
    "policy-random",
    "policy-slru",
    "policy-clock",
    "policy-clock-pro",
    "policy-nru",
]
policy-fifo = []
policy-lru = []
policy-fast-lru = []
policy-lru-k = []
policy-lfu = []
policy-heap-lfu = []
policy-two-q = []
policy-s3-fifo = []
policy-arc = []
policy-car = []
policy-lifo = []
policy-mfu = []
policy-mru = []
policy-random = []
policy-slru = []
policy-clock = []
policy-clock-pro = []
policy-nru = []

[dependencies]
parking_lot = { version = "0.12", optional = true }
rustc-hash = "2.1"
serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
bench-support = { path = "bench-support" }
criterion = "0.8"
dhat = "0.3"
lru = "0.16"
quick_cache = "0.6"
serde_json = "1.0"
chrono = "0.4"
proptest = "1.11"
arbitrary = { version = "1.4", features = ["derive"] }

# =============================================================================
# Benchmarks - organized by purpose
# =============================================================================

# Cross-policy workload comparison (single source of truth)
[[bench]]
name = "workloads"
harness = false

# Micro-operations (get/insert latency for all policies)
[[bench]]
name = "ops"
harness = false

# External crate comparison (lru, quick_cache)
[[bench]]
name = "comparison"
harness = false

# Human-readable reports (not criterion, just prints tables)
[[bench]]
name = "reports"
harness = false

# JSON artifact runner (produces target/benchmarks/<run-id>/results.json)
[[bench]]
name = "runner"
harness = false

# Policy-specific unique operations
[[bench]]
name = "policy_lru"
path = "benches/policy/lru.rs"
harness = false

[[bench]]
name = "policy_lfu"
path = "benches/policy/lfu.rs"
harness = false

[[bench]]
name = "policy_lru_k"
path = "benches/policy/lru_k.rs"
harness = false

[[bench]]
name = "policy_s3_fifo"
path = "benches/policy/s3_fifo.rs"
harness = false

# Development profile - optimized for fast compilation and good debugging
[profile.dev]
opt-level = 0
debug = true
debug-assertions = true
overflow-checks = true
lto = false
panic = "unwind"
incremental = true
codegen-units = 256

# Test profile - balanced for test execution speed vs debugging
[profile.test]
opt-level = 1
debug = true
debug-assertions = true
overflow-checks = true
lto = false
incremental = true
codegen-units = 256

# Release profile - maximum performance for production
[profile.release]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
lto = "fat"
panic = "abort"
codegen-units = 1
strip = true

# Benchmark profile - optimized for consistent performance measurement
[profile.bench]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
lto = "thin"
codegen-units = 1
strip = true
