"""ttl_cache_list utility.""" import time from typing import List from cachetools import TTLCache, cached def _list_hash(lst: List): return ",".join([str(elem) for elem in lst]) def ttl_cache_list(func): """ttl_cache for func with list argument.""" wrapper = cached( TTLCache(maxsize=128, ttl=600, timer=time.monotonic), key=_list_hash ) return wrapper(func)