Is there a way to reset the cache for a task withi...
# ask-community
d
Is there a way to reset the cache for a task within the flow?
n
hmm - there's the `refresh_cache=True` kwarg for tasks, but that's sort of coupled to the task call itself there are eventual incoming improvements to how caching works in general, but for now you may otherwise need to interact directly with your result storage, like deleting some glob of files if you stored task results with some
result_storage_key
j
You can also run your flow run with the env var/prefect setting
PREFECT_TASKS_REFRESH_CACHE=True
and it will refresh everything: https://docs.prefect.io/latest/concepts/tasks/?h=refresh#refreshing-the-cache
d
@Nate can you elaborate further on how I might invalidate the cache for a specific task by interacting directly with result storage? I see that ~/.prefect/storage contains some json type files, but they don't specifically seem to relate to a given task. Is there something in prefect.db that I can directly manipulate?
@Jake Kaplan You previously mentioned to me about creating my own cache key function. Do you think that may be relevant here for invalidating the results of a specific task if I'm able to pass a parameter that differs?
n
are you using
result_storage_key
? that way you can template the result files with names that later identifiable example of using storage key
d
Is it something I can use the with_option parameter with? I have a single task that I'm reusing
n
yep you can use with_options here!
d
and then there should be files under storage directory that I can just delete?
n
yep!
d
I'll give it a try, thanks