purge-rule.md 3.3 KB


title: "PurgeRule" isDefaultIndex: false

generated: true

import MemberInfo from '@site/src/components/MemberInfo'; import GenerationInfo from '@site/src/components/GenerationInfo'; import MemberDescription from '@site/src/components/MemberDescription';

PurgeRule

Defines a rule that listens for a particular VendureEvent and uses that to make calls to the Stellate Purging API via the provided StellateService instance.

class PurgeRule<Event extends VendureEvent = VendureEvent> {
    eventType: Type<Event>
    bufferTimeMs: number | undefined
    handle(handlerArgs: { events: Event[]; stellateService: StellateService; injector: Injector }) => ;
    constructor(config: PurgeRuleConfig<Event>)
}
### eventType ### bufferTimeMs ### handle StellateService; injector: Injector }) => `} /> ### constructor PurgeRuleConfig<Event>) => PurgeRule`} />

PurgeRuleConfig

Configures a PurgeRule.

interface PurgeRuleConfig<Event extends VendureEvent> {
    eventType: Type<Event>;
    bufferTime?: number;
    handler: (handlerArgs: {
        events: Event[];
        stellateService: StellateService;
        injector: Injector;
    }) => void | Promise<void>;
}
### eventType Specifies which VendureEvent will trigger this purge rule. ### bufferTime How long to buffer events for in milliseconds before executing the handler. This allows us to efficiently batch calls to the Stellate Purge API. ### handler StellateService; injector: Injector; }) => void | Promise<void>`} /> The function to invoke when the specified event is published. This function should use the StellateService instance to call the Stellate Purge API.