<@ULVA73B9P> what is the eviction policy of task c...
# marvin-ai
r
@Marvin what is the eviction policy of task cache?
m
thought for 187.5 seconds
Short answer: there isn’t an automatic eviction policy. In Prefect 3.x: - Cross-run task cache (the thing you get with
cache_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:
Copy code
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.