Skip to main content

PurgeRule

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.

Signature
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

property
Type<Event>

bufferTimeMs

property
number | undefined

handle

method
(handlerArgs: { events: Event[]; stellateService: StellateService; injector: Injector }) =>

constructor

method
(config: PurgeRuleConfig<Event>) => PurgeRule

PurgeRuleConfig

Configures a PurgeRule.

Signature
interface PurgeRuleConfig<Event extends VendureEvent> {
eventType: Type<Event>;
bufferTime?: number;
handler: (handlerArgs: {
events: Event[];
stellateService: StellateService;
injector: Injector;
}) => void | Promise<void>;
}

eventType

property
Type<Event>

Specifies which VendureEvent will trigger this purge rule.

bufferTime

property
number
default:
5000

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

property
(handlerArgs: { events: Event[]; stellateService: 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.