***

title: "PurgeRule"
generated: true
---------------

<GenerationInfo sourceFile="packages/stellate-plugin/src/purge-rule.ts" sourceLine="49" packageName="@vendure-community/stellate-plugin" />

Defines a rule that listens for a particular VendureEvent and uses that to
make calls to the [Stellate Purging API](https://docs.stellate.co/docs/purging-api) via
the provided [StellateService](/current/community-plugins/reference/stellate-plugin/stellate-service#stellateservice) instance.

```ts title="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>)
}
```

<div className="members-wrapper">

### eventType

\<MemberInfo kind="property" type={`Type<Event>`}   />

### bufferTimeMs

\<MemberInfo kind="property" type={`number | undefined`}   />

### handle

\<MemberInfo kind="method" type={`(handlerArgs: { events: Event[]; stellateService: <a href='/current/community-plugins/reference/stellate-plugin/stellate-service#stellateservice'>StellateService</a>; injector: Injector }) => `}   />

### constructor

\<MemberInfo kind="method" type={`(config: <a href='/current/community-plugins/reference/stellate-plugin/purge-rule#purgeruleconfig'>PurgeRuleConfig</a><Event>) => PurgeRule`}   />

</div>
<GenerationInfo sourceFile="packages/stellate-plugin/src/purge-rule.ts" sourceLine="13" packageName="@vendure-community/stellate-plugin" />

Configures a [PurgeRule](/current/community-plugins/reference/stellate-plugin/purge-rule#purgerule).

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

<div className="members-wrapper">

### eventType

\<MemberInfo kind="property" type={`Type<Event>`}   />

Specifies which VendureEvent will trigger this purge rule.

### bufferTime

\<MemberInfo kind="property" type={`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

\<MemberInfo kind="property" type={`(handlerArgs: {         events: Event[];         stellateService: <a href='/current/community-plugins/reference/stellate-plugin/stellate-service#stellateservice'>StellateService</a>;         injector: Injector;     }) => void | Promise<void>`}   />

The function to invoke when the specified event is published. This function should use the
[StellateService](/current/community-plugins/reference/stellate-plugin/stellate-service#stellateservice) instance to call the Stellate Purge API.

</div>
