lru

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

Library
Cargo
v0.18.5
838 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
72 /100 Good
Development Activity 88
Maintenance 48
Community 64
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
72 /100 Good
Architecture 70
Code Quality 74
Innovation 62
Learning Curve 80

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

Rust
54%
Other

Cap

Team Chat · Video Conferencing

22,884

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
64
Dependency
Built with
Rust 54%
TypeScript 42%
Updated 4 days ago
Rust
99%
Other

Fluree DB

Databases

469

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
87
Repo Health
74
Technical
65
Dependency
Built with
Rust 99%
Updated 5 days ago
Python
82%
Apache 2.0

headroom

AI Development · Developer Tools

73,966

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
85
Repo Health
86
Technical
69
Dependency
Built with
Python 82%
Rust 12%
Updated 5 days ago
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,529

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
65
Dependency
Built with
TypeScript 67%
Vue 25%
Updated 6 days ago
Dart
80%
Apache 2.0

LocalSend

Networking

92,857

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
Dart 80%
Rust 17%
Updated 5 days ago
Rust
100%
Other

Meilisearch

Search

59,424

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

View details
89
Repo Health
88
Technical
68
Dependency
Built with
Rust 100%
Updated 1 weeks ago
C++
66%
Other

Memgraph

AI Development · Databases

4,581

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

View details
90
Repo Health
79
Technical
69
Dependency
Built with
C++ 66%
Python 18%
Updated 5 days ago
Python
75%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

38,819

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

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 75%
Rust 12%
Updated 4 days ago
Rust
50%
Apache 2.0

Vibe Kanban

AI Agents · AI Code Assistants · Project Management

28,209

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
75
Repo Health
75
Technical
64
Dependency
Built with
Rust 50%
TypeScript 46%
Updated 1 weeks 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