cachetools
Extensible memoizing collections and decorators
Decision gist · record as of 2026-08-14
Yes. cachetools is a mature, actively maintained library with no dependencies, permissive licensing, and strong adoption. Install it if you need caching beyond what functools.lru_cache offers—particularly for TTL expiration, custom eviction policies, or fine-grained cache control. The low friction and zero security issues make it a safe, practical choice.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Installation is straightforward with no runtime dependencies and a pure-Python wheel distribution.
- The project is actively maintained with a recent release and shows strong community adoption.
License · maintenance · safety
MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
last release 2026-08-01 (13 days) · last repo commit 2026-08-01 · 2,776 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 345,317,933 downloads/mo, #119 on PyPI
Alternatives
Verify before relying
pip install cachetools
from cachetools import cached, LRUCache
@cached(cache=LRUCache(maxsize=32))
def expensive_function(n):
return n * 2- Performance characteristics and memory overhead compared to functools.lru_cache for typical workloads.
- Thread-safety guarantees for concurrent access to cache instances.
- Behavior when cache keys are unhashable or mutable objects.
What it is and what it does
cachetools is a Python library that provides memoizing collections and decorators for caching function results with pluggable eviction strategies. It extends the capabilities of the standard library's @lru_cache by offering multiple cache implementations—LRU (least recently used), TTL (time-to-live), FIFO, and others—allowing you to choose the right cache behavior for your use case. You decorate a function with @cached and pass a cache instance, and the library handles storing and retrieving results automatically.
The library is designed for scenarios where you need fine-grained control over cache behavior: limiting memory use with a maximum size, expiring cached data after a time window, or using alternative eviction policies. It has no external runtime dependencies, installs cleanly, and supports modern Python versions. It's commonly used in web applications, data processing pipelines, and any code path where repeated computation of the same inputs is expensive.
Use it for
- Speed up recursive algorithms like Fibonacci by caching intermediate results with @cached decorator.
- Cache API responses or database queries with TTLCache to refresh data periodically without manual invalidation.
- Implement a bounded memory cache for expensive computations using LRUCache with a fixed maxsize.
- Replace functools.lru_cache when you need custom eviction policies or time-based expiration.
- Build multi-tier caching in data pipelines where different functions need different cache strategies.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
cachetools is a mature, actively maintained library with no dependencies, permissive licensing, and strong adoption. Install it if you need caching beyond what functools.lru_cache offers—particularly for TTL expiration, custom eviction policies, or fine-grained cache control. The low friction and zero security issues make it a safe, practical choice.
Install
cachetools on PyPI
Before you install
Installation is straightforward with no runtime dependencies and a pure-Python wheel distribution. The project is actively maintained with a recent release and shows strong community adoption.
Requires Python 3.10 or later.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
Quickstart
pip install cachetools
from cachetools import cached, LRUCache
@cached(cache=LRUCache(maxsize=32))
def expensive_function(n):
return n * 2
Verify before relying
- Performance characteristics and memory overhead compared to functools.lru_cache for typical workloads.
- Thread-safety guarantees for concurrent access to cache instances.
- Behavior when cache keys are unhashable or mutable objects.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 13 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 345,317,933 / month, #119 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries :: Python Modules |
Evidence: cachetools-7.1.7-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “memoizing collections”
- cachetoolsProvides memoizing collections and function decorators for caching…
- cacheboxCachebox is a high-performance in-memory caching library written in…
- CFGraphCFGraph extends rdflib's Graph to read RDF collections as flattened…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also memoization · shelved-cache · pylru · methodtools · asyncache · cachebox · cachetools-async · onecache · klepto · functools32