Skip to content

Instantly share code, notes, and snippets.

View jmdacruz's full-sized avatar

Marcelo Da Cruz Pinto jmdacruz

View GitHub Profile
@jmdacruz
jmdacruz / timed_cache.py
Last active July 26, 2022 13:40 — forked from Morreski/timed_cache.py
Python lru_cache with timeout
from datetime import datetime, timedelta
import functools
def timed_cache(**timedelta_kwargs):
def _wrapper(f):
maxsize = timedelta_kwargs.pop('maxsize', 128)
typed = timedelta_kwargs.pop('typed', False)
update_delta = timedelta(**timedelta_kwargs)