MCPcopy
hub / github.com/directus/directus / clearSystemCache

Function clearSystemCache

api/src/cache.ts:97–117  ·  view source on GitHub ↗
(opts?: {
	forced?: boolean | undefined;
	autoPurgeCache?: false | undefined;
})

Source from the content-addressed store, hash-verified

95}
96
97export async function clearSystemCache(opts?: {
98 forced?: boolean | undefined;
99 autoPurgeCache?: false | undefined;
100}): Promise<void> {
101 const { systemCache, localSchemaCache, lockCache } = getCache();
102
103 // Flush system cache when forced or when system cache lock not set
104 if (opts?.forced || !(await lockCache.get('system-cache-lock'))) {
105 await lockCache.set('system-cache-lock', true, 10000);
106 await systemCache.clear();
107 await lockCache.delete('system-cache-lock');
108 }
109
110 await localSchemaCache.clear();
111 memorySchemaCache = null;
112
113 // Since a lot of cached permission function rely on the schema it needs to be cleared as well
114 await clearPermissionCache();
115
116 messenger.publish<CacheMessage>('schemaChanged', { autoPurgeCache: opts?.autoPurgeCache });
117}
118
119export async function setSystemCache(key: string, value: any, ttl?: number): Promise<void> {
120 const { systemCache, lockCache } = getCache();

Callers 15

flushCachesFunction · 0.85
utils.tsFile · 0.85
cacheClearFunction · 0.85
handlerFunction · 0.85
clearCachesMethod · 0.85
clearCachesMethod · 0.85
createOneMethod · 0.85
createManyMethod · 0.85
updateOneMethod · 0.85
updateBatchMethod · 0.85
updateManyMethod · 0.85
deleteOneMethod · 0.85

Calls 6

getCacheFunction · 0.70
getMethod · 0.65
setMethod · 0.65
clearMethod · 0.65
deleteMethod · 0.65
publishMethod · 0.65

Tested by

no test coverage detected