--- id: expiring-dict version: "1.1.2" license: unclear license_treatment: permissive maintenance: aging --- # expiring-dict — Python dict with TTL support for auto-expiring caches License: permissive · Maintenance: aging · Downloads: 185.5K/mo ## 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 above — verify before relying. ExpiringDict is a Python dictionary that automatically removes keys after a specified time-to-live (TTL) expires, supporting both class-level and per-key TTL configuration for building auto-expiring caches. 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 pip install expiring-dict uv add expiring-dict poetry add expiring-dict ## Installing expiring-dict 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: not declared (permissive) - Python support: unspecified - Install friction: low - Maintenance: aging - Downloads: 185.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags python dict with ttl, auto-expiring cache, key expiration dictionary, time-to-live cache, temporary key storage, cache with timeout, expiring dictionary, caching, ttl, auto-expiring [View on SkillFed](https://skillfed.io/packages/expiring-dict) · [View on PyPI](https://pypi.org/project/expiring-dict/)