<p align="center">
<a href="https://datarootsio.github.io/expiring-lru-cache/"><img alt="logo" src="https://raw.githubusercontent.com/datarootsio/expiring-lru-cache/main/docs/images/logo.png" height="200"></a>
</p>
# `expiring_lru_cache`
<p align="left">
<a href="https://dataroots.io"><img alt="Maintained by dataroots" src="https://dataroots.io/maintained-rnd.svg" /></a>
<a href="https://pypi.org/project/expiring-lru-cache/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/expiring-lru-cache" /></a>
<a href="https://pypi.org/project/expiring-lru-cache/"><img alt="PiPy" src="https://img.shields.io/pypi/v/expiring-lru-cache" /></a>
<a href="https://pepy.tech/project/expiring-lru-cache"><img alt="Downloads" src="https://pepy.tech/badge/expiring-lru-cache" /></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg" /></a>
<a href="http://mypy-lang.org/"><img alt="Mypy checked" src="https://img.shields.io/badge/mypy-checked-1f5082.svg" /></a>
<a href="https://app.codecov.io/gh/datarootsio/expiring-lru-cache"><img alt="Codecov" src="https://codecov.io/github/datarootsio/expiring-lru-cache/main/graph/badge.svg" /></a>
<a href="https://github.com/datarootsio/expiring-lru-cache/actions"><img alt="test" src="https://github.com/datarootsio/expiring-lru-cache/actions/workflows/tests.yml/badge.svg" /></a>
</p>
`expiring_lru_cache` is a minimal drop-in replacement of `functools.lru_cache`. It
allows the user to specify a time interval (in secs) after which the cache is
invalidated and reset.
## Usage
Here an example cached function whose cache will invalidate after 10 seconds.
```python
from expiring_lru_cache import lru_cache
@lru_cache(expires_after=10)
def my_plus_one_func(x: int) -> int:
return x + 1
```
Here an example cached function whose cache will invalidate after 1 day. Note that the
convenience variables `MINUTES`, `HOURS` and `DAYS` are available within the
`expiring_lru_cache` namespace.
```python
from expiring_lru_cache import lru_cache, DAYS
@lru_cache(expires_after=1 * DAYS)
def my_plus_one_func(x: int) -> int:
return x + 1
```
Raw data
{
"_id": null,
"home_page": "https://datarootsio.github.io/expiring-lru-cache/",
"name": "expiring-lru-cache",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.7",
"maintainer_email": null,
"keywords": "caching, expiration, drop-in, replacement",
"author": "Murilo Kuniyoshi Suzart Cunha",
"author_email": "murilo@dataroots.io",
"download_url": "https://files.pythonhosted.org/packages/4f/6b/e281e03a3ca0e10bfff20894294c892e5295e7f0baafed8225d2b6e29459/expiring_lru_cache-0.1.1.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <a href=\"https://datarootsio.github.io/expiring-lru-cache/\"><img alt=\"logo\" src=\"https://raw.githubusercontent.com/datarootsio/expiring-lru-cache/main/docs/images/logo.png\" height=\"200\"></a>\n</p>\n\n# `expiring_lru_cache`\n<p align=\"left\">\n <a href=\"https://dataroots.io\"><img alt=\"Maintained by dataroots\" src=\"https://dataroots.io/maintained-rnd.svg\" /></a>\n <a href=\"https://pypi.org/project/expiring-lru-cache/\"><img alt=\"Python versions\" src=\"https://img.shields.io/pypi/pyversions/expiring-lru-cache\" /></a>\n <a href=\"https://pypi.org/project/expiring-lru-cache/\"><img alt=\"PiPy\" src=\"https://img.shields.io/pypi/v/expiring-lru-cache\" /></a>\n <a href=\"https://pepy.tech/project/expiring-lru-cache\"><img alt=\"Downloads\" src=\"https://pepy.tech/badge/expiring-lru-cache\" /></a>\n <a href=\"https://github.com/psf/black\"><img alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\" /></a>\n <a href=\"http://mypy-lang.org/\"><img alt=\"Mypy checked\" src=\"https://img.shields.io/badge/mypy-checked-1f5082.svg\" /></a>\n <a href=\"https://app.codecov.io/gh/datarootsio/expiring-lru-cache\"><img alt=\"Codecov\" src=\"https://codecov.io/github/datarootsio/expiring-lru-cache/main/graph/badge.svg\" /></a>\n <a href=\"https://github.com/datarootsio/expiring-lru-cache/actions\"><img alt=\"test\" src=\"https://github.com/datarootsio/expiring-lru-cache/actions/workflows/tests.yml/badge.svg\" /></a>\n</p>\n\n`expiring_lru_cache` is a minimal drop-in replacement of `functools.lru_cache`. It\nallows the user to specify a time interval (in secs) after which the cache is\ninvalidated and reset.\n\n## Usage\n\nHere an example cached function whose cache will invalidate after 10 seconds.\n\n```python\nfrom expiring_lru_cache import lru_cache\n\n@lru_cache(expires_after=10)\ndef my_plus_one_func(x: int) -> int:\n return x + 1\n```\n\nHere an example cached function whose cache will invalidate after 1 day. Note that the\nconvenience variables `MINUTES`, `HOURS` and `DAYS` are available within the\n`expiring_lru_cache` namespace.\n\n```python\nfrom expiring_lru_cache import lru_cache, DAYS\n\n\n@lru_cache(expires_after=1 * DAYS)\ndef my_plus_one_func(x: int) -> int:\n return x + 1\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "LRU caching with expiration period.",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://datarootsio.github.io/expiring-lru-cache/",
"Repository": "https://github.com/datarootsio/expiring-lru-cache"
},
"split_keywords": [
"caching",
" expiration",
" drop-in",
" replacement"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "02309cd093daa9899edfbbf05691a608b8a5e9d329b26072c764ef75b0b816b8",
"md5": "d0464f2385228d9b63e1467e89445033",
"sha256": "016ab8770a3848c74103476f888553305659210fa88b9cf296f5427f81e8b359"
},
"downloads": -1,
"filename": "expiring_lru_cache-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d0464f2385228d9b63e1467e89445033",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.7",
"size": 4670,
"upload_time": "2024-06-30T12:02:52",
"upload_time_iso_8601": "2024-06-30T12:02:52.067152Z",
"url": "https://files.pythonhosted.org/packages/02/30/9cd093daa9899edfbbf05691a608b8a5e9d329b26072c764ef75b0b816b8/expiring_lru_cache-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4f6be281e03a3ca0e10bfff20894294c892e5295e7f0baafed8225d2b6e29459",
"md5": "85fa3a965e46aca3f8c49492624010b9",
"sha256": "dc5bd99cdd344345782557a7bf5e6526966299a4e8b7eb373eda10f869bfc7d5"
},
"downloads": -1,
"filename": "expiring_lru_cache-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "85fa3a965e46aca3f8c49492624010b9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.7",
"size": 3473,
"upload_time": "2024-06-30T12:02:53",
"upload_time_iso_8601": "2024-06-30T12:02:53.723520Z",
"url": "https://files.pythonhosted.org/packages/4f/6b/e281e03a3ca0e10bfff20894294c892e5295e7f0baafed8225d2b6e29459/expiring_lru_cache-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-30 12:02:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "datarootsio",
"github_project": "expiring-lru-cache",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "expiring-lru-cache"
}