mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
clear item cache when permissions change (#18526)
* clear item cache when permissions change * Create slow-timers-fold.md * Add tests --------- Co-authored-by: ian <licitdev@gmail.com>
This commit is contained in:
@@ -82,36 +82,66 @@ export class PermissionsService extends ItemsService {
|
||||
override async createOne(data: Partial<Item>, opts?: MutationOptions) {
|
||||
const res = await super.createOne(data, opts);
|
||||
await clearSystemCache({ autoPurgeCache: opts?.autoPurgeCache });
|
||||
|
||||
if (this.cache && opts?.autoPurgeCache !== false) {
|
||||
await this.cache.clear();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
override async createMany(data: Partial<Item>[], opts?: MutationOptions) {
|
||||
const res = await super.createMany(data, opts);
|
||||
await clearSystemCache({ autoPurgeCache: opts?.autoPurgeCache });
|
||||
|
||||
if (this.cache && opts?.autoPurgeCache !== false) {
|
||||
await this.cache.clear();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
override async updateBatch(data: Partial<Item>[], opts?: MutationOptions) {
|
||||
const res = await super.updateBatch(data, opts);
|
||||
await clearSystemCache({ autoPurgeCache: opts?.autoPurgeCache });
|
||||
|
||||
if (this.cache && opts?.autoPurgeCache !== false) {
|
||||
await this.cache.clear();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
override async updateMany(keys: PrimaryKey[], data: Partial<Item>, opts?: MutationOptions) {
|
||||
const res = await super.updateMany(keys, data, opts);
|
||||
await clearSystemCache({ autoPurgeCache: opts?.autoPurgeCache });
|
||||
|
||||
if (this.cache && opts?.autoPurgeCache !== false) {
|
||||
await this.cache.clear();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
override async upsertMany(payloads: Partial<Item>[], opts?: MutationOptions) {
|
||||
const res = await super.upsertMany(payloads, opts);
|
||||
await clearSystemCache({ autoPurgeCache: opts?.autoPurgeCache });
|
||||
|
||||
if (this.cache && opts?.autoPurgeCache !== false) {
|
||||
await this.cache.clear();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
override async deleteMany(keys: PrimaryKey[], opts?: MutationOptions) {
|
||||
const res = await super.deleteMany(keys, opts);
|
||||
await clearSystemCache({ autoPurgeCache: opts?.autoPurgeCache });
|
||||
|
||||
if (this.cache && opts?.autoPurgeCache !== false) {
|
||||
await this.cache.clear();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user