Revital Eres
12/04/2025, 1:59 PMMarvin
12/04/2025, 1:59 PMMarvin
12/04/2025, 2:02 PMcache_policy=...) is time-based. You control validity with `cache_expiration`; once expired, entries are ignored but not automatically deleted. There’s no LRU/size-based eviction. Old rows accumulate until you clean them up (e.g., DB maintenance).
- Within a single flow run, results can be cached in-memory (cache_result_in_memory=True by default). That cache is scoped to the engine process/run and is cleared when the run ends—no LRU/size-based eviction there either.
Example:
from datetime import timedelta
from prefect import task
@task(cache_policy=INPUTS, cache_expiration=timedelta(hours=1))
def my_task(x):
return x + 1
To force a refresh and bypass cache, set refresh_cache=True on the task decorator or when calling the task.
If you meant a specific cache (cross-run vs in-memory) or are running self-hosted and want cleanup strategies, let me know your setup and I can tailor guidance.