LRU caching with expiration period.
Project description
expiring_lru_cache
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.
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.
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file expiring_lru_cache-0.1.1.tar.gz
.
File metadata
- Download URL: expiring_lru_cache-0.1.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.14 Linux/6.5.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc5bd99cdd344345782557a7bf5e6526966299a4e8b7eb373eda10f869bfc7d5 |
|
MD5 | 85fa3a965e46aca3f8c49492624010b9 |
|
BLAKE2b-256 | 4f6be281e03a3ca0e10bfff20894294c892e5295e7f0baafed8225d2b6e29459 |
File details
Details for the file expiring_lru_cache-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: expiring_lru_cache-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.14 Linux/6.5.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 016ab8770a3848c74103476f888553305659210fa88b9cf296f5427f81e8b359 |
|
MD5 | d0464f2385228d9b63e1467e89445033 |
|
BLAKE2b-256 | 02309cd093daa9899edfbbf05691a608b8a5e9d329b26072c764ef75b0b816b8 |