From a7f7a63792a54ef0c242f77510fe91fdf0ee102b Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Sat, 25 Mar 2023 17:33:31 +0100 Subject: [PATCH] Make server settings cache key a function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Huge thanks to @sebjulliand for suggesting this! Co-authored-by: Sébastien Julliand --- src/api/Storage.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/Storage.ts b/src/api/Storage.ts index 74a1e2b1d..4785f36b9 100644 --- a/src/api/Storage.ts +++ b/src/api/Storage.ts @@ -5,7 +5,7 @@ const LAST_PROFILE_KEY = `currentProfile`; const SOURCE_LIST_KEY = `sourceList`; const DEPLOYMENT_KEY = `deployment`; const DEBUG_KEY = `debug`; -const SERVER_SETTINGS_CACHE_KEY = `serverSettingsCache`; +const SERVER_SETTINGS_CACHE_KEY = (name : string) => `serverSettingsCache_${name}`; export type PathContent = Record; export type DeploymentPath = Record; @@ -84,15 +84,15 @@ export class GlobalStorage extends Storage { } getServerSettingsCache(name: string) { - return this.get(SERVER_SETTINGS_CACHE_KEY.concat(`_${name}`)); + return this.get(SERVER_SETTINGS_CACHE_KEY(name)); } async setServerSettingsCache(name: string, serverSettings: CachedServerSettings) { - await this.set(SERVER_SETTINGS_CACHE_KEY.concat(`_${name}`), serverSettings); + await this.set(SERVER_SETTINGS_CACHE_KEY(name), serverSettings); } async deleteServerSettingsCache(name: string) { - await this.set(SERVER_SETTINGS_CACHE_KEY.concat(`_${name}`), undefined); + await this.set(SERVER_SETTINGS_CACHE_KEY(name)), undefined); }} export class ConnectionStorage extends Storage {