(opts?: {
forced?: boolean | undefined;
autoPurgeCache?: false | undefined;
})
| 95 | } |
| 96 | |
| 97 | export 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 | |
| 119 | export async function setSystemCache(key: string, value: any, ttl?: number): Promise<void> { |
| 120 | const { systemCache, lockCache } = getCache(); |
no test coverage detected