Skip to content

Commit

Permalink
clear cache event
Browse files Browse the repository at this point in the history
  • Loading branch information
DovMa committed Apr 10, 2024
1 parent c645412 commit fce9748
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
10 changes: 0 additions & 10 deletions services/fishStockings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,6 @@ export type FishStocking<
all: ['beforeSelect', 'handleSort'],
export: ['beforeSelect', 'handleSort'],
},
after: {
review: ['handleCache'],
updateFishStocking: ['handleCache'],
remove: ['handleCache'],
},
},
actions: {
remove: {
Expand Down Expand Up @@ -1336,9 +1331,4 @@ export default class FishStockingsService extends moleculer.Service {
);
}
}

@Method
async handleCache() {
await this.broker.cacher.clean('public.**');
}
}
15 changes: 13 additions & 2 deletions services/public.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import { format } from 'date-fns';
import moleculer, { Context } from 'moleculer';
import { Action, Method, Service } from 'moleculer-decorators';
import { RestrictionType } from '../types';
import { Action, Event, Method, Service } from 'moleculer-decorators';
import { EntityChangedParams, RestrictionType } from '../types';
import { FishStocking } from './fishStockings.service';
import { CompletedFishBatch, FishStockingsCompleted } from './fishStockingsCompleted.service';
import { TenantUser } from './tenantUsers.service';

const uetkStatisticsParams = {
date: [
Expand Down Expand Up @@ -245,4 +246,14 @@ export default class FishAgesService extends moleculer.Service {
return aggregate;
}, {} as BatchesById);
}

@Event()
async 'fishStockings.*'(ctx: Context<EntityChangedParams<TenantUser>>) {
switch (ctx.params.type) {
case 'create':
case 'update':
case 'remove':
await this.broker.cacher.clean('public.**');
}
}
}

0 comments on commit fce9748

Please sign in to comment.