Skip to content

Instantly share code, notes, and snippets.

View stephengolub's full-sized avatar

Stephen Golub stephengolub

  • San Antonio, TX
View GitHub Profile
@stephengolub
stephengolub / lru_cache_ttl.py
Last active July 18, 2022 20:57 — forked from kgriffs/lru_cache_ttl.py
Grant Jenks' LRU Cache with TTL for Python
# Grant Jenks' LRU Cache with TTL for Python
#
# https://stackoverflow.com/questions/31771286/python-in-memory-cache-with-time-to-live/71634221#71634221
from functools import lru_cache, wraps
from time import monotonic
import typing as t
def lru_cache_with_ttl(