cachetools

In-memory memoizing cache collections and decorators for Python, beyond the standard library's lru_cache

Library
PyPI
v7.2.4
2,790 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
76 /100 Good
Development Activity 96
Maintenance 52
Community 56
Maturity 60
Momentum 40

Technical Analysis

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

cachetools provides various memoizing collections and decorators for Python, including variants of the standard library’s @lru_cache function decorator. A cache in this module is a mutable mapping of a fixed maximum size; when full, the cache discards items based on a chosen cache algorithm (LRU, LFU, TTL, FIFO, RR, and more).

The library exposes both cache classes (LRUCache, TTLCache, etc.) that behave as regular dict-like mappings, and @cached/@cachedmethod decorators that wrap functions or methods to transparently memoize their results against any of those cache instances, including thread-safe usage via an explicit lock argument.

What You Get

  • Cache classes implementing LRU, LFU, TTL, FIFO, RR, and other eviction algorithms as dict-like mutable mappings
  • @cached and @cachedmethod decorators for memoizing plain functions and instance/class methods
  • A keys module for building custom cache keys from function arguments (e.g. ignoring specific parameters)
  • Thread-safe usage support via an explicit lock argument on the decorators
  • A func module offering functools.lru_cache-compatible drop-in decorators backed by cachetools’ cache classes

Common Use Cases

  • Memoizing expensive pure-function calls (recursive algorithms, API lookups) with an LRU or TTL bound
  • Caching per-instance computed properties or expensive method calls via @cachedmethod
  • Rate-limiting external API calls by caching responses for a fixed TTL window
  • Replacing ad-hoc dict-based caches with a maintained, size-bounded, thread-safe alternative

Under The Hood

Architecture - The package is organized as a small src/cachetools module: __init__.py (774 lines) defines the cache classes (Cache, LRUCache, LFUCache, TTLCache, FIFOCache, RRCache, etc.) as subclasses of a shared MutableMapping-based base, _cached.py and _cachedmethod.py implement the decorator logic separately for functions vs. methods, and keys.py provides key-generation helpers used by the decorators. Tech Stack - Pure Python with no runtime dependencies, using only the standard library’s collections.abc and time modules; packaged with a standard pyproject.toml/src-layout build. Code Quality - 14 test modules under tests/ cover the individual cache classes and decorators, CI runs via GitHub Actions with Codecov coverage reporting badges shown in the README, and the codebase is stable/mature (mature project per repo-health signals) with infrequent but steady maintenance. API Design - the cache classes are deliberately dict-like (MutableMapping subclasses), so users already familiar with Python dicts can drop them in directly; the @cached(cache=...) decorator mirrors functools.lru_cache’s ergonomics while accepting any cache instance, keeping the public surface small and consistent across eviction strategies.

Used by 18 apps in this directory

TypeScript
54%
Other

OpenReplay

Analytics

13,042

Self-hosted session replay and product analytics suite that lets you see exactly what users do on your web app — without sending data to third parties.

View details
91
Repo Health
77
Technical
66
Dependency
Built with
TypeScript 54%
Go 13%
Updated 6 days ago
Python
49%
Other

Arize Phoenix

Analytics · Devops · Monitoring

11,976

Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.

View details
92
Repo Health
88
Technical
67
Dependency
Built with
Python 49%
TypeScript 43%
Updated 5 days ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

40,397

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 5 days ago
Python
87%
Apache 2.0

PrivateGPT

AI Development

57,611

The open-source API layer that turns local LLMs into production private AI applications with full Claude API compatibility

View details
88
Repo Health
83
Technical
70
Dependency
Built with
Python 87%
Updated 6 days ago
Python
57%
Other

Sentry

Analytics · Developer Tools · Monitoring

45,632

Developer-first error tracking and performance monitoring platform with AI-powered root-cause analysis across 20+ languages and frameworks.

View details
95
Repo Health
80
Technical
66
Dependency
Built with
Python 57%
TypeScript 42%
Updated 5 days ago
Python
64%
AGPL 3.0

Shadowbroker

Analytics · Monitoring · Security

11,358

Self-hosted OSINT dashboard that fuses 60+ live intelligence feeds — flight tracking, ship AIS, satellites, CCTV, seismic and radio networks — into one real-time map, with an agent-ready command channel for AI co-analysts.

View details
85
Repo Health
83
Technical
71
Dependency
Built with
Python 64%
TypeScript 32%
Updated 6 days ago
Python
79%
AGPL 3.0

Skyvern

AI Agents · Automation

23,257

Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.

View details
89
Repo Health
82
Technical
70
Dependency
Built with
Python 79%
TypeScript 19%
Updated 5 days ago
Python
97%
MPL 2.0

Taiga Back

Developer Tools · Project Management

859

Self-hosted agile project management backend with Scrum, Kanban, issue tracking, and a full REST API — built on Django and PostgreSQL.

View details
72
Repo Health
74
Technical
64
Dependency
Built with
Python 97%
Updated 1 months ago
Python
68%
AGPL 3.0

Tracecat

AI Agents · Automation · Security

3,860

Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.

View details
89
Repo Health
88
Technical
66
Dependency
Built with
Python 68%
TypeScript 30%
Updated 5 days 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