lru

A simple, fast O(1) LRU cache implementation for Rust

Library
Cargo
v0.18.2
831stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
62/100Good
Development Activity68
Maintenance28
Community64
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
72/100Good
Architecture70
Code Quality74
Innovation62
Learning Curve80

lru is a minimal, dependency-light LRU (least-recently-used) cache for Rust, providing put, get, get_mut, and pop operations that all run in O(1) time. It was originally derived from the LRU cache implementation once found in an early version of Rust’s own std::collections before that module was removed, and remains one of the most widely depended-upon caching crates in the Rust ecosystem.

The crate is intentionally small in scope — a single LruCache type backed by an internal hash map and doubly linked list — making it easy to audit, embed, and use in both std and no_std (via the optional hashbrown backend) environments.

What You Get

  • A generic LruCache<K, V> type with O(1) put/get/get_mut/pop/peek operations
  • Optional hashbrown-backed hash map for faster lookups and no_std support
  • Iterator support for inspecting cache contents in recency order
  • A nightly feature flag for opting into nightly-only hashbrown optimizations
  • Zero required runtime dependencies beyond the optional hashbrown backend

Common Use Cases

  • Bounding memory use of an in-process cache (e.g. parsed config, compiled regexes, DB query results)
  • Implementing eviction policy for a connection pool or object pool
  • Building a simple in-memory HTTP response or asset cache inside a Rust web service
  • Embedding a bounded cache inside a no_std or embedded Rust project via the hashbrown backend

Under The Hood

Architecture — The entire implementation lives in a single src/lib.rs (~3,200 lines including tests and docs), structured around an internal hash map from keys to nodes of a doubly-linked list; get/put move the touched node to the front of the list while pop/eviction removes from the back, giving the classic O(1) LRU behavior without a separate background thread or lock. Tech Stack — Pure Rust with a 1.85.0 MSRV, categorized under caching and no-std on crates.io; the only dependency is the optional hashbrown crate (enabled by default) used as a faster/no_std-compatible hash map, with scoped_threadpool and stats_alloc present only as dev-dependencies for benchmarking. Code Quality — The crate carries an extensive inline test suite directly in lib.rs covering capacity edge cases, eviction order, and the get_mut/peek variants, plus a CHANGELOG.md tracking version-by-version behavior changes, indicating a project that takes API stability seriously despite its small surface area. API Design — The API deliberately mirrors the ergonomics of std::collections::HashMap (put/get/get_mut/pop) so it requires almost no learning curve for anyone familiar with Rust’s standard collections, and the NonZeroUsize capacity parameter statically rules out the common zero-capacity-cache bug at the type level.

Used by 9 apps in this directory

TypeScript
55%
Other

Cap

Team Chat · Video Conferencing

20,986

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
Rust
100%
Other

Fluree DB

Databases

445

A temporal, verifiable graph database with git-like branching, integrated vector/text/geo search, and RDF/SPARQL/JSON-LD/openCypher support — benchmarked at 10.4x faster than the next database on the full Wikidata dump.

View details
86
Repo Health
74
Technical
65
Dependency
Built with
Rust100%
Updated yesterday
Python
80%
Apache 2.0

headroom

AI Development · Developer Tools

66,835

Compress everything your AI agent reads — tool outputs, logs, RAG chunks, and files — before it reaches the LLM, achieving 60–95% fewer tokens with the same answers.

View details
84
Repo Health
86
Technical
73
Dependency
Built with
Python80%
Rust14%
Updated today
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
Dart
80%
Apache 2.0

LocalSend

Networking

88,691

An open-source, cross-platform AirDrop alternative that sends files and messages device-to-device over your local network with no internet, no account, and no cloud server involved.

View details
89
Repo Health
61
Technical
78
Dependency
Built with
Dart80%
Rust17%
Updated today
Rust
100%
Other

Meilisearch

Search

59,012

Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.

View details
90
Repo Health
88
Technical
68
Dependency
Built with
Rust100%
Updated 5 days ago
C++
66%
Other

Memgraph

Databases · AI Development

4,347

High-performance in-memory graph database for AI context and real-time analytics

View details
90
Repo Health
79
Technical
70
Dependency
Built with
C++66%
Python18%
Updated today
Python
74%
AGPL 3.0

OpenViking

Databases · AI Development

29,711

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
84
Repo Health
75
Technical
65
Dependency
Built with
Python74%
Rust14%
Updated today
Rust
50%
Apache 2.0

Vibe Kanban

AI Agents · AI Code Assistants · Project Management

27,849

A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.

View details
53
Repo Health
75
Technical
65
Dependency
Built with
Rust50%
TypeScript46%
Updated 3 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search