skillfed

expiringdict

Dictionary with auto-expiring values for caching purposes

expiringdict v1.2.2 10.9M downloads/30d#1,429 on PyPI
Permissive license Apache 2 Abandoned released

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 on this page — 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

expiringdict on PyPI

pip

pip install expiringdict

uv

uv add expiringdict

poetry

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 not specified
Install friction low — pure-Python wheel
Runtime dependencies 1 — typing
Maintenance abandoned — 1,515 days since the last release
First released
Downloads 10,875,172/month — #1,429 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: expiringdict-1.2.2-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.6Topic :: Software Development :: Libraries

Tags

expiring cache dictionaryauto-expiring dicttime-based cache evictionttl dictionaryordered cache with expiryin-memory cache with timeoutcaching library python
cachingttlin-memory

More Libraries packages