tower-http-cache 0.5.1

Tower-compatible caching layer with pluggable backends (in-memory, Redis, and more)
Documentation
[package]
name = "tower-http-cache"
version = "0.5.1"
edition = "2021"
# 1.85 covers the default feature set and everything except the shared
# backends. `redis-backend` and `memcached-backend` both pull `url` -> `idna`
# -> `icu_*`, which require 1.88; there is no Cargo.lock in this repo, so a
# consumer resolving fresh gets those versions too. Both floors are enforced
# by separate CI jobs.
rust-version = "1.85"
description = "Tower-compatible caching layer with pluggable backends (in-memory, Redis, and more)"
license = "MIT OR Apache-2.0"
repository = "https://github.com/sadco-io/tower-http-cache"
documentation = "https://docs.rs/tower-http-cache"
readme = "README.md"
exclude = ["._*", "**/.DS_Store", ".cursor/"]
keywords = ["tower", "cache", "middleware", "http"]
categories = ["web-programming", "caching"]
authors = ["Daniel Curtis <drc@danielryancurtis.com>"]

[dependencies]
tower = { version = "0.5.3", default-features = false, features = ["util"] }
http = { version = "1.5", default-features = false }
http-body = "1.1"
http-body-util = "0.1.5"
async-trait = "0.1"
bytes = "1.12"
tokio = { version = "1.53", features = ["sync", "rt", "time", "macros"] }
# Optional: only the JSON-shaped surfaces need these -- the codec (backend
# serialization), `CacheEvent` (structured JSON logging) and the admin API.
# The core in-memory cache path does not.
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
moka = { version = "0.12.16", optional = true, features = ["future"] }
redis = { version = "0.32.7", features = ["aio", "tokio-comp", "connection-manager"], optional = true }
tokio-util = { version = "0.7.19", optional = true }
async-memcached = { version = "0.5", optional = true }
bb8 = { version = "0.8", optional = true }
metrics = { version = "0.24", optional = true }
pin-project-lite = "0.2"
thiserror = "2.0"
dashmap = "6.2"
futures-util = { version = "0.3.34", default-features = false, features = ["alloc"] }
bincode = { version = "1.3.3", optional = true }
tracing = { version = "0.1", optional = true }
flate2 = { version = "1.1", optional = true, default-features = false, features = ["rust_backend"] }
uuid = { version = "1.25", features = ["v4", "serde"] }
sha2 = "0.10"
hex = "0.4"
chrono = "0.4.45"
axum = { version = "0.8.9", optional = true }

[features]
default = ["in-memory", "serde"]
in-memory = ["moka"]
redis-backend = ["redis", "tokio-util", "serde"]
memcached-backend = ["async-memcached", "dep:bb8", "serde"]
serde = ["dep:serde", "dep:serde_json", "dep:bincode"]
metrics = ["dep:metrics"]
tracing = ["dep:tracing"]
compression = ["dep:flate2"]
admin-api = ["dep:axum", "serde"]

[dev-dependencies]
tokio = { version = "1.53", features = ["full"] }
tower = { version = "0.5.3", features = ["util"] }
http-body-util = "0.1.5"
axum = "0.8.9"
redis = { version = "0.32.7", features = ["aio", "tokio-comp", "connection-manager"] }
tracing-subscriber = { version = "0.3.23", features = ["fmt", "env-filter"] }
criterion = { version = "0.7", features = ["html_reports"] }
# No-op recorder for the `metrics` bench in cache_benchmarks.rs.
metrics-util = { version = "0.20", default-features = false, features = ["debugging"] }

# Every integration test and example is built on a concrete backend, so each
# declares the feature that provides it. Without these, `cargo test` on a
# reduced feature set fails to resolve the backend type.
[[test]]
name = "auto_refresh"
required-features = ["in-memory"]

[[test]]
name = "cache_stale"
required-features = ["in-memory"]

[[test]]
name = "integration_cache"
required-features = ["in-memory"]

[[test]]
name = "streaming"
required-features = ["in-memory"]

[[test]]
name = "redis_example"
required-features = ["redis-backend"]

[[example]]
name = "chunk_cache_demo"
required-features = ["in-memory"]

[[example]]
name = "v0_3_features"
required-features = ["in-memory", "serde"]

[[example]]
name = "axum_redis"
required-features = ["redis-backend"]

[[example]]
name = "redis_smoke"
required-features = ["redis-backend"]

[[example]]
name = "memcached_production"
required-features = ["memcached-backend"]

[[bench]]
name = "cache_benchmarks"
harness = false
required-features = ["in-memory"]