Example of a custom caching function (:thread:)
# pacc-clearcover-june-12-2023
e
Example of a custom caching function (🧵)
Copy code
from prefect.tasks import task_input_hash

def cache_within_flow_run(context, parameters):
    return f"{context.task_run.flow_run_id}-{task_input_hash(context, parameters)}"

@task(cache_key_fn=cache_within_flow_run)
def cached_task():
    print('running an expensive operation')
    return 42