mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Flush cache when applying diff (#18986)
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
This commit is contained in:
5
.changeset/strange-peaches-heal.md
Normal file
5
.changeset/strange-peaches-heal.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@directus/api": patch
|
||||
---
|
||||
|
||||
Ensured all caches are flushed when applying diff
|
||||
@@ -86,7 +86,7 @@ export async function clearSystemCache(opts?: {
|
||||
forced?: boolean | undefined;
|
||||
autoPurgeCache?: false | undefined;
|
||||
}): Promise<void> {
|
||||
const { systemCache, localSchemaCache, lockCache } = getCache();
|
||||
const { systemCache, localSchemaCache, lockCache, sharedSchemaCache } = getCache();
|
||||
|
||||
// Flush system cache when forced or when system cache lock not set
|
||||
if (opts?.forced || !(await lockCache.get('system-cache-lock'))) {
|
||||
@@ -95,6 +95,7 @@ export async function clearSystemCache(opts?: {
|
||||
await lockCache.delete('system-cache-lock');
|
||||
}
|
||||
|
||||
await sharedSchemaCache.clear();
|
||||
await localSchemaCache.clear();
|
||||
messenger.publish('schemaChanged', { autoPurgeCache: opts?.autoPurgeCache });
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { Diff, DiffDeleted, DiffNew } from 'deep-diff';
|
||||
import deepDiff from 'deep-diff';
|
||||
import type { Knex } from 'knex';
|
||||
import { cloneDeep, merge, set } from 'lodash-es';
|
||||
import { clearSystemCache } from '../cache.js';
|
||||
import { flushCaches } from '../cache.js';
|
||||
import { getHelpers } from '../database/helpers/index.js';
|
||||
import getDatabase from '../database/index.js';
|
||||
import emitter from '../emitter.js';
|
||||
@@ -324,7 +324,7 @@ export async function applyDiff(
|
||||
await helpers.schema.postColumnChange();
|
||||
}
|
||||
|
||||
await clearSystemCache();
|
||||
await flushCaches();
|
||||
|
||||
if (nestedActionEvents.length > 0) {
|
||||
const updatedSchema = await getSchema({ database, bypassCache: true });
|
||||
|
||||
Reference in New Issue
Block a user