Skip to content

Commit

Permalink
Name config object cacheSeconds instead of cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ptlthg committed Sep 26, 2024
1 parent f3185cf commit 9c284ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/cachetimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function isCacheExpired(unixMs, cacheTime) {
* @returns {boolean} Whether the cache is expired
*/
export function isProfileCacheExpired(unixMs) {
return isCacheExpired(unixMs, credentials.cache.profiles);
return isCacheExpired(unixMs, credentials.cacheSeconds.profiles);
}

/**
Expand All @@ -25,7 +25,7 @@ export function isProfileCacheExpired(unixMs) {
* @returns {boolean} Whether the cache is expired
*/
export function isMuseumCacheExpired(unixMs) {
return isCacheExpired(unixMs, credentials.cache.museum);
return isCacheExpired(unixMs, credentials.cacheSeconds.museum);
}

/**
Expand All @@ -34,7 +34,7 @@ export function isMuseumCacheExpired(unixMs) {
* @returns {boolean} Whether the cache is expired
*/
export function isGuildCacheExpired(unixMs) {
return isCacheExpired(unixMs, credentials.cache.guild);
return isCacheExpired(unixMs, credentials.cacheSeconds.guild);
}

/**
Expand All @@ -43,5 +43,5 @@ export function isGuildCacheExpired(unixMs) {
* @returns {boolean} Whether the cache is expired
*/
export function isBingoProfileCacheExpired(unixMs) {
return isCacheExpired(unixMs, credentials.cache.bingoProfiles);
return isCacheExpired(unixMs, credentials.cacheSeconds.bingoProfiles);
}
10 changes: 5 additions & 5 deletions src/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const defaultCredentials = {
get session_secret() {
return randomBytes(32).toString("hex");
},
cache: {
cacheSeconds: {
profiles: 60 * 5, // 5 minutes
bingoProfile: 60 * 5, // 5 minutes
museum: 60 * 30, // 30 minutes
Expand Down Expand Up @@ -88,19 +88,19 @@ if (process.env.DISCORD_WEBHOOK) {
}

if (process.env.CACHE_PROFILES && isFinite(parseInt(process.env.CACHE_PROFILES))) {
CREDENTIALS.cache.profiles = parseInt(process.env.CACHE_PROFILES);
CREDENTIALS.cacheSeconds.profiles = parseInt(process.env.CACHE_PROFILES);
}

if (process.env.CACHE_MUSEUM && isFinite(parseInt(process.env.CACHE_MUSEUM))) {
CREDENTIALS.cache.museum = parseInt(process.env.CACHE_MUSEUM);
CREDENTIALS.cacheSeconds.museum = parseInt(process.env.CACHE_MUSEUM);
}

if (process.env.CACHE_GUILD && isFinite(parseInt(process.env.CACHE_GUILD))) {
CREDENTIALS.cache.guild = parseInt(process.env.CACHE_GUILD);
CREDENTIALS.cacheSeconds.guild = parseInt(process.env.CACHE_GUILD);
}

if (process.env.CACHE_BINGO_PROFILE && isFinite(parseInt(process.env.CACHE_BINGO_PROFILE))) {
CREDENTIALS.cache.bingoProfile = parseInt(process.env.CACHE_BINGO_PROFILE);
CREDENTIALS.cacheSeconds.bingoProfile = parseInt(process.env.CACHE_BINGO_PROFILE);
}

export default CREDENTIALS;

0 comments on commit 9c284ce

Please sign in to comment.