bincache
Overview
- Simple API
- Flexible cache sizing, limiting, and eviction
- Multiple cache strategies for different use cases
- Support for cache compression
- Best-effort cache recovery
Cache Strategies
Bincache uses a strategy pattern to allow for different caching strategies:
- In-memory cache
- Disk-backed cache
- Hybrid cache (in-memory + disk-backed)
- Custom strategies possible through
CacheStrategy
Compression Algorithms
Bincache supports various compression algorithms:
- Gzip (feature:
comp_gzip) - Brotli (feature:
comp_brotli) - Zstandard (feature:
comp_zstd) - Custom algorithms possible through
CompressionStrategy
Async Runtimes
Bincache supports multiple async runtimes:
- Futures-compatible (default)
- Tokio 1.x (feature:
rt_tokio_1) - Async-Std 1.x (feature:
rt_async-std_1)
Usage
-
Add
bincacheto your project: -
Create a
Cacheinstance with your preferred strategy:async -
That's it!
Library Features
blocking- Enables blocking stdlib I/Ort_tokio_1- Enables tokio 1.x supportrt_async-std_1- Enables async-std 1.x supportcomp_zstd- Enables zstd compression supportcomp_gzip- Enables gzip compression supportcomp_brotli- Enabled brotli compression support
By default, we enable a "soft"
implicit-blockingfeature, which only uses blocking I/O if no other runtime feature is enabled.You can explicitly opt-in to blocking I/O by enabling the
blockingfeature, which will disallow the use ofrt_tokio_1andrt_async-std_1.