Skip to main content

TTL Cache

PyPI - Version PyPI - Python Version CI codecov Docs

An LRU cache decorator with a time to live like functools.lru_cache, but entries expire after a configurable number of seconds.

Installation

pip install ttl-cache-decorator

Usage

from ttl_cache import ttl_lru_cache


@ttl_lru_cache(ttl=30)
def fetch_user(user_id: int) -> dict:
    return {"id": user_id, "name": "Ada"}


fetch_user(1)  # Calls the function
fetch_user(1)  # Cache hit
# ... 30 seconds later ...
fetch_user(1)  # Expired — calls the function again

License

ttl-cache-decorator is distributed under the terms of the MIT license.

Metadata

Release files for ttl-cache-decorator 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ttl-cache-decorator 0.1.4
File Size Uploaded Provenance Actions
ttl_cache_decorator-0.1.4.tar.gz 56.1 kB With provenance Details for ttl_cache_decorator-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ttl-cache-decorator 0.1.4
File Interpreter ABI Platform Actions
ttl_cache_decorator-0.1.4-py3-none-any.whl Python 3 none any Details for ttl_cache_decorator-0.1.4-py3-none-any.whl

Total release size: 60.3 kB

Release files / ttl_cache_decorator-0.1.4.tar.gz

Download URL ttl_cache_decorator-0.1.4.tar.gz
Size 56.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d3fb86af04d559932f62930c4080e1c6297a7bcf4bf62134216ec222b0328cc3
BLAKE2b-256 checksum
How to use checksums
ab1aa05f72c71ca7591f627a33e4b5baab8e4eafaa4550a287065d9db3e18bc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / ttl_cache_decorator-0.1.4-py3-none-any.whl

Download URL ttl_cache_decorator-0.1.4-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32ea086aa3fa0cee41ea0268f6bebc8928ee9a05847cc82e9dc60afc3aff7d8c
BLAKE2b-256 checksum
How to use checksums
d7d1b5b072452977795ef432e47eeb0320ea03ba3d8d284aa663e391f237e234
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for ttl-cache-decorator 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ttl_cache_decorator-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page