persist_result=True
on a task definition.
Output
DEFAULT
cache policy, which is a composite cache policy defined as:
TASK_SOURCE
component of the DEFAULT
cache policy helps avoid naming collisions between similar tasks that should not share a cache.cache_policy=INPUTS
in the task decorator:
x=1
, but will not sleep for any subsequent calls with the same input.
Prefect ships with several cache policies that can be used to customize caching behavior.
INPUTS
cache policy.
cache_expiration
parameter on the task decorator.
refresh_cache
parameter on the task decorator.
PREFECT_TASKS_REFRESH_CACHE
setting.
Setting PREFECT_TASKS_REFRESH_CACHE=true
changes the default behavior of all tasks to refresh.
If you have tasks that should not refresh when this setting is enabled, set refresh_cache
to False
. These tasks will never write to the cache. If a cache key exists it will be read, not updated.
If a cache key does not exist yet, these tasks can still write to the cache.
+
operator.
~/.prefect/storage/
. To share the cache across tasks running on different machines, provide a storage block to the result_storage
parameter on the task decorator.
Here’s an example with of a task that uses an S3 bucket to store cache records:
prefect_aws
package must be installed to use the S3Bucket
storage block.