expiring-lru-cache


Nameexpiring-lru-cache JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://datarootsio.github.io/expiring-lru-cache/
SummaryLRU caching with expiration period.
upload_time2024-03-20 15:10:12
maintainerNone
docs_urlNone
authorMurilo Kuniyoshi Suzart Cunha
requires_python<4.0,>=3.7
licenseMIT
keywords caching expiration drop-in replacement
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <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/f8/53/868c13a706b2909f53ae4895d5665614aba18d57b6f6aa0246a84d9bec42/expiring_lru_cache-0.1.0.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.0",
    "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": "7f0be6d29e9f93a5e7c2a6d7d7a2d01ed32b87ae37c1c6dcfaf980878f95e07b",
                "md5": "1723a80241130109f2b0f45c20068bac",
                "sha256": "1a92d9605126ea2f57ddbb4b762bb5771bb749352a5fdc828f369132ca6d6a4f"
            },
            "downloads": -1,
            "filename": "expiring_lru_cache-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1723a80241130109f2b0f45c20068bac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.7",
            "size": 4662,
            "upload_time": "2024-03-20T15:10:10",
            "upload_time_iso_8601": "2024-03-20T15:10:10.795190Z",
            "url": "https://files.pythonhosted.org/packages/7f/0b/e6d29e9f93a5e7c2a6d7d7a2d01ed32b87ae37c1c6dcfaf980878f95e07b/expiring_lru_cache-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f853868c13a706b2909f53ae4895d5665614aba18d57b6f6aa0246a84d9bec42",
                "md5": "59bd55ab64b0d60bc8c4c348c9bae3da",
                "sha256": "3517992080c5e5343f822b7a3bdf59ced1d84c97ce57fa64757752c708fadd82"
            },
            "downloads": -1,
            "filename": "expiring_lru_cache-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "59bd55ab64b0d60bc8c4c348c9bae3da",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.7",
            "size": 3454,
            "upload_time": "2024-03-20T15:10:12",
            "upload_time_iso_8601": "2024-03-20T15:10:12.387494Z",
            "url": "https://files.pythonhosted.org/packages/f8/53/868c13a706b2909f53ae4895d5665614aba18d57b6f6aa0246a84d9bec42/expiring_lru_cache-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-20 15:10:12",
    "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"
}
        
Elapsed time: 0.25802s