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
Close
Hashes for expiring_lru_cache-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a51d1afb86d599ed9eab1e68465c6b154b8aca11f94d7395037d2daaa1ac0feb |
|
MD5 | b5c7858eb8122887f3b0477664dfc1a1 |
|
BLAKE2b-256 | 42326721dddee5f639db5a5f9c69fbb6437ac1773c98fafabbbd905f9ec50143 |