InvalidationRule¶
The dataclass that connects a Django model's signals to a
CachedWrapper. See the
Invalidation Rules guide
for an overview and worked examples.
InvalidationRule
dataclass
¶
InvalidationRule(
model: type[Model],
rewarm: bool = False,
field_mapping: dict[str, str] = dict(),
require_args: bool | list[str] = True,
trigger_on_create: bool = False,
watch_fields: list[str] | None = None,
invalidate_when: dict[str, Any] = dict(),
invalidator: Callable[..., None] | str | None = None,
dispatcher: str | type[Dispatcher] | None = None,
dispatcher_config: dict[str, Any] = dict(),
batch: bool = False,
raise_exception: bool | None = None,
)
Declarative rule that connects a Django model's signals to cache invalidation.
A rule invalidates in one of two ways: a field_mapping that maps cache-key argument names onto attributes of the saving instance, or a custom invalidator callable that takes over the work.