Skip to content

Commit

Permalink
Make server settings cache key a function
Browse files Browse the repository at this point in the history
Huge thanks to @sebjulliand for suggesting this!

Co-authored-by: Sébastien Julliand <sebjulliand@gmail.com>
  • Loading branch information
chrjorgensen and sebjulliand authored Mar 25, 2023
1 parent f1d44c6 commit a7f7a63
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/api/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string[]>;
export type DeploymentPath = Record<string, string>;
Expand Down Expand Up @@ -84,15 +84,15 @@ export class GlobalStorage extends Storage {
}

getServerSettingsCache(name: string) {
return this.get<CachedServerSettings>(SERVER_SETTINGS_CACHE_KEY.concat(`_${name}`));
return this.get<CachedServerSettings>(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 {
Expand Down

0 comments on commit a7f7a63

Please sign in to comment.