cachekit-rs 0.6.0

Production-ready caching for Rust. Supports cachekit.io SaaS, Redis, Memcached, local File, and Cloudflare Workers.
Documentation
[package]
name = "cachekit-rs"
version = "0.6.0"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
description = "Production-ready caching for Rust. Supports cachekit.io SaaS, Redis, Memcached, local File, and Cloudflare Workers."
readme = "../../README.md"
homepage = "https://cachekit.io"
keywords = ["cache", "redis", "encryption", "moka", "cloudflare-workers"]
categories = ["caching", "web-programming", "cryptography"]

[lib]
name = "cachekit"

[features]
default = ["cachekitio", "encryption", "l1", "reliability"]
cachekitio = ["dep:reqwest", "dep:serde_json"]
redis = ["dep:fred"]
# Memcached backend (native only). rust-memcache is sync (r2d2-pooled, socket
# read/write timeouts); ops run on tokio's blocking pool via spawn_blocking,
# each under a tokio/time budget so a wedged server can't hang callers.
memcached = ["dep:memcache", "tokio/rt", "tokio/time"]
# Local filesystem backend (native only). tokio/rt provides spawn_blocking so
# disk I/O never blocks the async executor; libc provides O_NOFOLLOW/ELOOP
# constants and rustix provides safe flock/geteuid on unix.
file = ["tokio/rt", "tokio/sync", "dep:libc", "dep:rustix"]
workers = ["dep:worker", "dep:js-sys", "dep:getrandom", "dep:serde_json"]
# cachekit-core's `encryption` feature folds aes-gcm in automatically on wasm32
# (`wasm` is a pure alias for `encryption`). No separate `cachekit-core/wasm`
# activation needed. Deliberately version-free: the fact is version-independent,
# and a pinned version in prose is the only part that rots (LAB-866 precedent).
encryption = ["cachekit-core/encryption"]
# tokio/rt provides Handle::try_current + spawn for the L1 stale-while-
# revalidate background refresh (native only — `workers`+`l1` is a compile
# error, so this never reaches wasm32).
l1 = ["dep:moka", "tokio/rt"]
macros = ["dep:cachekit-macros"]
# Retry with backoff + circuit breaker around backend ops, and cross-process
# cold-miss suppression via LockableBackend. Native only (needs tokio timers).
reliability = ["tokio/time"]
# Opt into ?Send / Rc on native targets (for tokio::task::LocalSet, single-threaded
# runtimes, etc.). Same code paths that wasm32 already uses.
unsync = []

[dependencies]
cachekit-core = { version = "0.4", features = ["messagepack"] }
serde = { version = "1", features = ["derive"] }
rmp-serde = "1"
thiserror = "2.0"
async-trait = "0.1"
blake2 = "0.10"
bytes = "1"
zeroize = { version = "1", features = ["derive"] }
urlencoding = "2"
hex = "0.4"
url = "2"
uuid = { version = "1", features = ["v4", "js"] }
# `sync` only: runtime-independent primitives for cold-miss single-flight.
# Compiles on wasm32. Features stack per consumer: `reliability` adds `time`
# (native only); the `memcached`/`file` backends add `rt` (spawn_blocking) —
# see the feature declarations above.
tokio = { version = "1", default-features = false, features = ["sync"] }

# Optional: HTTP backend (native)
reqwest = { version = "0.12", optional = true, default-features = false, features = ["rustls-tls", "json"] }
serde_json = { version = "1", optional = true }

# Optional: Redis backend. `i-scripts` exposes EVAL for the atomic
# compare-and-delete lock release (LockableBackend).
fred = { version = "9", optional = true, features = ["i-scripts"] }

# Optional: Memcached backend. rust-memcache with no default features — the
# `tls` feature would pull openssl into a rustls-only SDK (and the previously
# used async-memcached 0.6 shipped toxiproxy_rust/openssl as runtime deps,
# which is why it was dropped — expert panel, LAB-429). Held at 0.19: 0.20.0
# uses `is_multiple_of`/let-chains and breaks this workspace's 1.85 MSRV.
memcache = { version = "0.19", optional = true, default-features = false }

# Optional: L1 in-process cache
moka = { version = "0.12", optional = true, features = ["sync"] }

# Optional: Cloudflare Workers
worker = { version = "0.4", optional = true }
js-sys = { version = "0.3", optional = true }
getrandom = { version = "0.2", optional = true, features = ["js"] }

# Optional: proc-macro decorator
cachekit-macros = { version = "0.6.0", path = "../cachekit-macros", optional = true }

# Optional (file backend, unix only): libc for the O_NOFOLLOW/ELOOP constants
# (std has no portable spelling); rustix for safe flock/geteuid wrappers —
# this workspace forbids `unsafe`, so raw libc calls are off the table.
[target.'cfg(unix)'.dependencies]
libc = { version = "0.2", optional = true }
rustix = { version = "1", optional = true, default-features = false, features = ["fs", "process", "std"] }

[dev-dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync", "time"] }
serde_json = "1"
serial_test = "3"
tempfile = "3"

[lints]
workspace = true