Skip to content

Commit e8a0bfd

Browse files
committed
refactor(GuildConfigCache): caching behaviour in fetch
1 parent 4abbbfc commit e8a0bfd

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Core/Stores/GuildConfigCache.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class GuildConfigsCache extends Store {
5656
} catch (err) {
5757
throw new AxonError(`Cannot retrieve guildConfig from the DB: Guild: ${key}\n${err.stack}`, 'AxonClient', 'GuildConfigsCache');
5858
}
59-
this.set(key, guildConfig);
6059
}
6160
return guildConfig;
6261
}
@@ -69,16 +68,19 @@ class GuildConfigsCache extends Store {
6968
* @memberof GuildConfigsCache
7069
*/
7170
async fetch(gID) {
71+
let guildConfig;
72+
7273
try {
73-
let guildConfig = await this._axon.DBProvider.fetchGuild(gID);
74+
guildConfig = await this._axon.DBProvider.fetchGuild(gID);
7475
if (!guildConfig) {
7576
guildConfig = await this._axon.DBProvider.initGuild(gID);
7677
}
77-
return guildConfig;
78-
} catch (err) {
79-
const newGuildConfig = await this._axon.DBProvider.initGuild(gID);
80-
return newGuildConfig;
78+
} catch (_) {
79+
guildConfig = await this._axon.DBProvider.initGuild(gID);
8180
}
81+
82+
this.set(gID, guildConfig);
83+
return guildConfig;
8284
}
8385

8486
/**

0 commit comments

Comments
 (0)