--- id: expiringdict version: "1.2.2" license: Apache 2 license_treatment: permissive maintenance: abandoned --- # expiringdict — Dictionary with auto-expiring values for caching purposes License: permissive · Maintenance: abandoned · Downloads: 10.9M/mo ## What it is and what it does ExpiringDict is a Python caching library that wraps a dictionary with automatic value expiration and capacity limits. It stores key-value pairs that are removed either when their time-to-live (max_age_seconds) expires or when the dictionary reaches its maximum size (max_len), at which point the oldest entries are deleted. Expiration is checked on any access to the dictionary, and the object is locked during cleanup to prevent concurrent modification issues. The package is useful for scenarios where you need a simple, in-memory cache with automatic cleanup. It supports initialization from regular dicts or other ExpiringDict instances, and can be pickled. Note that iteration over the dictionary and the keys() method do not trigger expiration of stale values—only direct access does. Use it for: - Caching API responses or database query results with automatic expiration after a set time. - Rate-limiting or throttling by tracking request counts that decay over time. - Session storage in web applications where sessions expire after inactivity. - Temporary storage of computed results that should be refreshed periodically. - Deduplication of recent events or messages with automatic cleanup. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. ExpiringDict is an ordered dictionary that automatically removes values after a specified time interval, with a fixed capacity limit, designed for caching purposes. Yes, if you need a simple, lightweight in-memory cache with automatic expiration and can tolerate the abandoned status. The library is stable and has no known vulnerabilities, but you should not expect bug fixes or new features. Consider alternatives if you need active maintenance, thread-safety guarantees beyond basic locking, or support for newer Python versions. ## Install pip install expiringdict uv add expiringdict poetry add expiringdict ## Installing expiringdict Before you install: Installation is straightforward with no compiled dependencies. However, the package is abandoned—last release was 1515 days ago with no recent maintenance activity, so expect no bug fixes or updates. License in practice: Licensed under Apache 2 (permissive), so you can use it freely in commercial and open-source projects without restrictive obligations. Quickstart: pip install expiringdict from expiringdict import ExpiringDict cache = ExpiringDict(max_len=100, max_age_seconds=10) cache["key"] = "value" print(cache.get("key")) Verify before relying: - Thread-safety guarantees during concurrent access beyond the stated locking during cleanup. - Performance characteristics with large capacity or high expiration rates. - Compatibility with Python versions beyond 3.6 given the abandoned status. ## Package facts - License: Apache 2 (permissive) - Python support: unspecified - Install friction: low - Maintenance: abandoned - Downloads: 10.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags expiring cache dictionary, auto-expiring dict, time-based cache eviction, ttl dictionary, ordered cache with expiry, in-memory cache with timeout, caching library python, caching, ttl, in-memory [View on SkillFed](https://skillfed.io/packages/expiringdict) · [View on PyPI](https://pypi.org/project/expiringdict/)