Feature/extensions always use fetch mutation to get list (#440)

* Reset the cache after importing a backup

* Add option to delete cached data after ttl is reached

* Always use mutation to get extensions list
This commit is contained in:
schroda
2023-11-04 22:40:38 +01:00
committed by GitHub
parent 2c35808ee4
commit 7cb062d453
3 changed files with 35 additions and 11 deletions

View File

@@ -32,8 +32,19 @@ export class CustomCache {
return this.keyToFetchTimestampMap.get(key);
}
public getResponseFor<Response = any>(endpoint: string, data: unknown): Response | undefined {
public getResponseFor<Response = any>(endpoint: string, data: unknown, ttl?: number): Response | undefined {
const key = this.getKeyFor(endpoint, data);
const isTtlReached = ttl && Date.now() - (this.getFetchTimestampFor(endpoint, data) ?? 0) >= ttl;
if (isTtlReached) {
this.keyToResponseMap.delete(key);
}
return this.keyToResponseMap.get(key) as Response;
}
public clear(): void {
this.keyToResponseMap.clear();
this.keyToFetchTimestampMap.clear();
}
}