A highly customizable async caching framework for Rust with Tower middleware, stale-while-revalidate, dogpile prevention, and pluggable backends.
Hitbox is an async caching framework for Rust designed for high-performance applications. It provides a protocol-agnostic core with first-class HTTP support, allowing developers to implement caching as middleware or via function memoization. The framework solves common caching challenges like dogpile effects and stale data by offering features like stale-while-revalidate and configurable concurrency limits.
Rust developers building high-performance web services or applications that require efficient caching, especially those using Tower-based frameworks like Axum or working with distributed systems.
Developers choose Hitbox for its extensibility, performance, and built-in optimizations. It offers a platform approach where new integrations automatically inherit advanced features like dogpile prevention and multi-layer caching, eliminating the need to re-implement these mechanisms for each project.
Async caching framework for Rust with Tower middleware, stale-while-revalidate, dogpile prevention, and pluggable backends (Moka, Redis, FeOxDB)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Load tests show 167,270 req/s throughput with caching vs 970 req/s without for slow upstreams, a 172x improvement, as detailed in the benchmarks section.
New backends and protocols can be added by implementing traits, automatically inheriting optimizations like dogpile prevention and composable caching without re-implementation.
Includes stale-while-revalidate with offload revalidation, configurable dogpile prevention via broadcast channels, and multi-tier backend composition for optimal performance.
Integrates with the metrics crate to provide cache hit/miss/stale counters, latency histograms, and backend I/O tracking, usable with exporters like Prometheus.
Even basic HTTP caching requires setting up predicates, extractors, and policies with multiple builder patterns, as shown in the Quick Start, which can be overwhelming for simple use cases.
YAML-based configuration is listed as 'TBA' (To Be Announced), forcing all caching rules to be defined in code and requiring recompilation for runtime changes.
Using JQ body predicates for JSON filtering adds 25-65 microseconds of overhead, which can be significant for low-latency applications, as noted in the benchmarks.
Tied to Rust's async runtime and Tower ecosystem, making it unsuitable for polyglot projects or teams unfamiliar with Rust's advanced trait system.