expiring-dict
Python dict with TTL support for auto-expiring caches
Decision gist · record as of 2026-08-14
Yes, if you need a lightweight, zero-configuration TTL dictionary for simple caching. The low install friction, permissive license, and recent maintenance make it a safe choice for projects that don't require advanced cache features. However, verify thread-safety and expiration semantics for your specific use case before relying on it in production.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction: pure Python wheel with a single runtime dependency (sortedcontainers).
- Last commit was recent (2025-02-28) and the repository is active, though the project is aging with no documented Python version requirement.
License · maintenance · safety
permissive license (permissive) — MIT license (permissive) means you can use, modify, and distribute this package freely with minimal restrictions, making it suitable for both open-source and commercial projects.
last release 2025-02-28 (532 days) · last repo commit 2025-02-28 · 25 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 185,521 downloads/mo, #10,009 on PyPI
Alternatives
Verify before relying
pip install expiring-dict
from expiring_dict import ExpiringDict
from time import sleep
cache = ExpiringDict(1) # 1-second TTL
cache["key"] = "value"
assert "key" in cache
sleep(1)
assert "key" not in cache # Expired- Whether expired keys are removed on access, on a background timer, or both
- Memory overhead and performance characteristics with large numbers of keys
- Thread-safety guarantees for concurrent access
What it is and what it does
ExpiringDict wraps Python's built-in dict to add automatic key expiration based on a time-to-live (TTL) value. You can set a default TTL at the class level so all keys expire after that duration, or assign individual TTLs to specific keys using the ttl() method for fine-grained control. Keys that have exceeded their TTL are no longer accessible via membership tests or lookups.
The package depends on sortedcontainers to manage the expiration timeline efficiently. It's designed for caching scenarios where you want temporary storage without manual cleanup—common in session management, rate-limiting, or transient data buffering. The aging maintenance status and lack of a documented Python version requirement suggest it's a stable but minimal project.
Use it for
- Session storage that automatically clears old sessions after a timeout period
- Rate-limiting buckets that reset after a fixed time window
- Temporary cache for API responses that should refresh after a TTL
- In-memory job queues where tasks expire if not processed within a deadline
- Transient request deduplication that forgets duplicate keys after a time window
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need a lightweight, zero-configuration TTL dictionary for simple caching.
The low install friction, permissive license, and recent maintenance make it a safe choice for projects that don't require advanced cache features. However, verify thread-safety and expiration semantics for your specific use case before relying on it in production.
Install
expiring-dict on PyPI
Before you install
Low install friction: pure Python wheel with a single runtime dependency (sortedcontainers). Last commit was recent (2025-02-28) and the repository is active, though the project is aging with no documented Python version requirement.
License in practice
MIT license (permissive) means you can use, modify, and distribute this package freely with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install expiring-dict
from expiring_dict import ExpiringDict
from time import sleep
cache = ExpiringDict(1) # 1-second TTL
cache["key"] = "value"
assert "key" in cache
sleep(1)
assert "key" not in cache # Expired
Verify before relying
- Whether expired keys are removed on access, on a background timer, or both
- Memory overhead and performance characteristics with large numbers of keys
- Thread-safety guarantees for concurrent access
Package facts
| License | permissive license permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagesortedcontainers |
| Maintenance | Aging 532 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 185,521 / month, #10,009 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 |
Evidence: expiring_dict-1.1.2-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 › “python dict with ttl”
- expiring-dictExpiringDict is a Python dictionary that automatically removes keys…
- expiringdictExpiringDict is an ordered dictionary that automatically removes…
- cachettlcachettl provides LRU TTL cache decorators for both synchronous and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities 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.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
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.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also expiringdict · cacheout · cachettl · onecache · memoization · django-session-timeout · async-lru · cachetools · cache-to-disk · pyarmor