oxcache 0.1.4

A high-performance multi-level cache library for Rust with L1 (memory) and L2 (Redis) caching.
Documentation
[package]
name = "oxcache"
version = "0.1.4"
edition = "2021"
description = "A high-performance multi-level cache library for Rust with L1 (memory) and L2 (Redis) caching."
authors = ["Kirky.X"]
license = "MIT"
repository = "https://github.com/kirky-x/oxcache"
readme = "README.md"
keywords = ["cache", "redis", "memory", "async", "performance"]
categories = ["caching", "asynchronous", "database"]

[lib]
name = "oxcache"
path = "src/lib.rs"

# ============================================================================
# MAIN DEPENDENCIES
# ============================================================================
[dependencies]
# Internal macros
oxcache_macros = { path = "macros", version = "0.1.3", optional = true }

# Async Runtime
tokio = { version = "1.32", features = ["full"] }
async-trait = "0.1"
lazy_static = "1.4"
once_cell = "1.18"

# Utilities
uuid = { version = "1.0", features = ["v4"] }
secrecy = { version = "0.8", features = ["serde"] }

# Error Handling
thiserror = "1.0"
anyhow = "1.0"

# Logging
log = "0.4"

# Configuration
toml = { version = "0.8", optional = true }

# Tracing for logging and instrumentation
tracing = { version = "0.1", optional = true }

# HTTP support for http-cache feature
[dependencies.http]
version = "1.0"
optional = true

[dependencies.tower]
version = "0.5"
optional = true

[dependencies.axum]
version = "0.8"
optional = true

[dependencies.hyper]
version = "1.0"
optional = true

[dependencies.http-body-util]
version = "0.1"
optional = true

# ============================================================================
# L1 CACHE DEPENDENCIES (Memory Cache)
# ============================================================================
[dependencies.moka]
version = "0.12"
default-features = false
features = ["future"]
optional = true

# In-memory concurrent map for internal state
[dependencies.dashmap]
version = "6.0"
optional = true

# ============================================================================
# L2 CACHE DEPENDENCIES (Redis Distributed Cache)
# ============================================================================
[dependencies.redis]
version = "0.27"
default-features = false
features = ["aio", "tokio-comp", "cluster-async", "sentinel", "connection-manager", "script"]
optional = true

# ============================================================================
# SERIALIZATION & COMPRESSION
# ============================================================================
[dependencies.serde]
version = "1.0"
default-features = false
features = ["derive", "alloc"]
optional = true

[dependencies.serde_json]
version = "1.0"
optional = true

[dependencies.flate2]
version = "1.0"
optional = true

[dependencies.bincode]
version = "1.3"
optional = true

# Extra serialization (MessagePack, CBOR)
[dependencies.rmp-serde]
version = "1.0"
optional = true

[dependencies.ciborium]
version = "0.2"
optional = true

[dependencies.md5]
version = "0.7"
optional = true

# ============================================================================
# DATABASE DEPENDENCIES
# ============================================================================
[dependencies.sea-orm]
version = "1.0.14"
default-features = false
features = ["sqlx-sqlite", "runtime-tokio-rustls", "macros"]
optional = true

[dependencies.sqlx]
version = "0.8"
default-features = false
features = ["sqlite", "runtime-tokio-rustls", "macros", "migrate"]
optional = true

# ============================================================================
# OBSERVABILITY & METRICS
# ============================================================================

[dependencies.opentelemetry]
version = "0.22"
optional = true

[dependencies.opentelemetry_sdk]
version = "0.22"
optional = true

[dependencies.tracing-opentelemetry]
version = "0.23"
optional = true

[dependencies.opentelemetry-otlp]
version = "0.15"
optional = true

[dependencies.tracing-subscriber]
version = "0.3"
default-features = false
features = ["env-filter", "fmt"]
optional = true

# ============================================================================
# UTILITIES
# ============================================================================
[dependencies.tokio-util]
version = "0.7"
optional = true

[dependencies.futures]
version = "0.3"
optional = true

[dependencies.regex]
version = "1.10"
optional = true

[dependencies.chrono]
version = "0.4"
default-features = false
features = ["serde", "clock"]
optional = true

# ============================================================================
# ADVANCED FEATURES
# ============================================================================
# Bloom filter for cache optimization
[dependencies.bloomfilter]
version = "2.0.0"
optional = true

# Murmur3 hash for bloom filters
[dependencies.murmur3]
version = "0.5"
optional = true

# ============================================================================
# CLI & CONFIGURATION
# ============================================================================
[dependencies.clap]
version = "4.4"
default-features = false
features = ["derive"]
optional = true

[dependencies.confers]
version = "0.1.1"
optional = true

# ============================================================================
# DEV DEPENDENCIES
# ============================================================================
[dev-dependencies]
tempfile = "3.8"
serial_test = "3.0"
rand = "0.8"
criterion = { version = "0.5", features = ["async_tokio"] }
ctor = "0.2"
mockall = "0.14.0"

# ============================================================================
# BUILD DEPENDENCIES
# ============================================================================
[build-dependencies]
anyhow = { version = "1.0", optional = true }


# ============================================================================
# FEATURE DEFINITIONS
# ============================================================================

[features]

# Default: Full feature set for maximum compatibility
default = ["full"]

# --------------------------------------------------------------------
# TIERED FEATURES (Build on top of individual features)
# --------------------------------------------------------------------

# Minimal: Only L1 memory cache - no Redis, no external services
minimal = [
    "l1-moka",
    "tokio/time",
    "dep:tracing",
    "metrics",
    "serialization",
    "chrono",
]

# Core: L1 + L2 basic functionality (Redis)
core = [
    "minimal",
    "l2-redis",
    "futures",
]

# Full: All features enabled
full = [
    "core",
    "macros",
    "bloom-filter",
    "rate-limiting",
    "wal-recovery",
    "database",
    "cli",
    "full-metrics",
    "batch-write",
    "confers",
    "codegen",
    "compression",
    "smart-strategy",
    "redis-native",
    "enhanced-stats",
    "ttl-control",
    "tiered-cache",
    "extra-serialization",
    "config-dynamic",
    "http-cache",
    "serialization-cache",
]

# --------------------------------------------------------------------
# COMPONENT FEATURES
# --------------------------------------------------------------------

# Cache Macros
macros = ["dep:oxcache_macros"]

# L1 Cache Implementation (Moka)
l1-moka = ["dep:moka", "dep:dashmap"]

# L2 Cache Implementation (Redis)
l2-redis = ["dep:redis"]

# Serialization Support
serialization = ["dep:serde", "dep:serde_json"]
bincode = ["serialization", "dep:bincode"]
compression = ["dep:flate2"]
flate2 = ["dep:flate2"]

# Serialization Cache
serialization-cache = ["serialization", "dep:dashmap"]

# Metrics & Observability
opentelemetry = ["dep:opentelemetry", "dep:opentelemetry_sdk", "dep:tracing-subscriber"]
metrics = ["opentelemetry", "dep:dashmap"]
full-metrics = ["metrics", "dep:tracing-opentelemetry", "dep:opentelemetry-otlp"]

# Database Integration
database = ["dep:sea-orm", "dep:sqlx", "dep:regex"]

# Advanced Features
bloom-filter = ["dep:bloomfilter", "dep:murmur3"]
rate-limiting = []
wal-recovery = []
batch-write = ["dep:tokio-util"]
sync = []

# Configuration
confers = ["dep:confers", "dep:toml"]

# Smart Strategy Features
smart-strategy = ["compression", "metrics", "l1-moka"]
redis-native = ["l2-redis"]
enhanced-stats = ["metrics"]
ttl-control = ["l2-redis"]
tiered-cache = ["l1-moka", "l2-redis"]
extra-serialization = ["dep:rmp-serde", "dep:ciborium"]
config-dynamic = ["confers"]
http-cache = ["serialization", "tiered-cache", "dep:md5", "dep:http", "dep:tower", "dep:axum", "dep:hyper", "dep:http-body-util"]

cli = ["dep:clap", "dep:dashmap", "dep:tracing", "metrics"]
codegen = ["dep:anyhow"] # Used for build scripts

# ============================================================================
# COMPILER OPTIMIZATIONS
# ============================================================================
# These optimizations are always applied regardless of features
[profile.release]
opt-level = 3
lto = "fat"              # Enable Link-Time Optimization for better dead code elimination
codegen-units = 1        # Single codegen unit for better optimization
panic = "abort"          # Smaller binary by removing panic unwinding
strip = true             # Remove debug symbols
overflow-checks = false  # Disable overflow checks in release

# Optimize all dependencies equally
[profile.release.package."*"]
opt-level = 3

# Dev profile optimizations
[profile.dev]
debug = true

[profile.test]
opt-level = 0