Skip to content

Cache Policies#

Magistrate Cache Policy#

The MAGISTRATE_CACHE_POLICY is a custom cache policy1 is used to assist in the creation of cache keys for a Prefect task. This should work near identically to the default policy (DEFAULT), but be able to handle inputs that are not hashable by default.

magistrate.MAGISTRATE_CACHE_POLICY module-attribute #

MAGISTRATE_CACHE_POLICY = CompoundCachePolicy(policies=[from_cache_key_fn(compute_inputs), TASK_SOURCE, RUN_ID])

Example

from prefect import task
from magistrate import MAGISTRATE_CACHE_POLICY

@task(cache_policy=MAGISTRATE_CACHE_POLICY)
def my_task(a, b):
    return a + b