Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Rust
  3. stretto

stretto

Apache-2.0Rustv0.2.0

A high-performance, thread-safe, memory-bound cache library for Rust, implementing Dgraph's Ristretto algorithm.

GitHubGitHub
431 stars28 forks0 contributors

What is stretto?

Stretto is a high-performance, thread-safe, memory-bound cache library for Rust. It implements Dgraph's Ristretto caching algorithm, providing efficient in-memory storage with optimized eviction and admission policies. It solves the problem of managing fast, concurrent access to frequently used data in Rust applications.

Target Audience

Rust developers building performance-sensitive applications such as web servers, databases, or real-time systems that require efficient in-memory caching.

Value Proposition

Developers choose Stretto for its proven Ristretto algorithm, which offers excellent hit ratios and throughput, full concurrency support, and both synchronous and asynchronous APIs without the overhead of external locks.

Overview

Stretto is a Rust implementation for Dgraph's ristretto (https://github.com/dgraph-io/ristretto). A high performance memory-bound Rust cache.

Use Cases

Best For

  • Implementing low-latency caching layers in Rust web servers
  • Optimizing database query results caching in Rust applications
  • Building high-throughput concurrent services requiring in-memory storage
  • Adding efficient caching to real-time data processing pipelines
  • Reducing external dependency overhead with a pure Rust cache solution
  • Scaling applications with customizable cost-based eviction policies

Not Ideal For

  • Projects requiring a simple, plug-and-play cache with zero configuration tuning
  • Embedded or resource-constrained systems where overhead from internal threads is prohibitive
  • Applications needing persistent or disk-backed cache storage beyond in-memory
  • Sync-only codebases that cannot tolerate the extra threads started by Cache (even in sync mode)

Pros & Cons

Pros

Proven High Performance

Implements Dgraph's Ristretto algorithm with SampledLFU eviction and TinyLFU admission, delivering best-in-class hit ratios for search and database traces as noted in the README.

Full Concurrency Without Locks

Supports internal mutability, eliminating the need for external Arc<RwLock> wrappers and allowing high-throughput concurrent access with minimal degradation.

Flexible Cost-Based Eviction

Allows eviction decisions based on customizable cost (e.g., bytes or arbitrary units), enabling large valuable items to displace multiple smaller ones for efficient memory use.

Runtime-Agnostic Async Support

Provides AsyncCache with a spawner parameter, making it compatible with any async runtime (e.g., Tokio) alongside a synchronous Cache API for versatility.

Cons

Configuration Complexity

Requires careful tuning of parameters like num_counters (10x expected items) and max_cost, which can be error-prone and non-intuitive for newcomers.

Internal Thread Overhead

Cache starts two extra OS threads in sync mode (policy and writing threads), adding runtime overhead that may impact lightweight applications.

Metrics Performance Hit

Enabling real-time metrics incurs a 10% throughput performance penalty, as admitted in the README, forcing a trade-off between observability and speed.

No Key Storage

Only stores hashed keys (via KeyBuilder) rather than the original keys, which limits direct key introspection and may complicate debugging or custom key handling.

Frequently Asked Questions

Quick Stats

Stars431
Forks28
Contributors0
Open Issues13
Last commit14 days ago
CreatedSince 2021

Tags

#async-rust#lfu-cache#high-performance#caching#database-cache#concurrent#rust-lang#cache#rust-library#rust-crate#rust#no-std

Built With

R
Rust

Included in

Rust56.6k
Auto-fetched 14 hours ago

Related Projects

sccachesccache

Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage.

Stars7,281
Forks669
Last commit2 days ago
mokamoka

A high performance concurrent caching library for Rust

Stars2,547
Forks121
Last commit1 month ago
cachedcached

Rust cache structures and easy function memoization

Stars2,010
Forks109
Last commit14 hours ago
cacache-rscacache-rs

A high-performance, concurrent, content-addressable disk cache, with support for both sync and async APIs. 💩💵 but for your 🦀

Stars704
Forks43
Last commit1 year ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub