from cachetools import cached, TTLCache cache = TTLCache(maxsize=100, ttl=86400) @cached(cache) def fatorial_com_cache(valor): if valor <= 1: return 1 else: return valor * fatorial_sem_cache(valor - 1)