forked from SkyCryptWebsite/SkyCrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcachetimes.js
More file actions
47 lines (42 loc) · 1.58 KB
/
Copy pathcachetimes.js
File metadata and controls
47 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import credentials from "./credentials.js";
/**
* Check if a resource is expired based on the cache time
* @param {number} unixMs Unix timestamp in milliseconds
* @param {number} cacheTime The cache time in seconds
* @returns {boolean} Whether the cache is expired
*/
export function isCacheExpired(unixMs, cacheTime) {
return Date.now() - unixMs > cacheTime * 1000;
}
/**
* Check if a profile cache is expired based on the configured cache time
* @param {number} unixMs Unix timestamp in milliseconds
* @returns {boolean} Whether the cache is expired
*/
export function isProfileCacheExpired(unixMs) {
return isCacheExpired(unixMs, credentials.cacheSeconds.profiles);
}
/**
* Check if a museum cache is expired based on the configured cache time
* @param {number} unixMs Unix timestamp in milliseconds
* @returns {boolean} Whether the cache is expired
*/
export function isMuseumCacheExpired(unixMs) {
return isCacheExpired(unixMs, credentials.cacheSeconds.museum);
}
/**
* Check if a guild cache is expired based on the configured cache time
* @param {number} unixMs Unix timestamp in milliseconds
* @returns {boolean} Whether the cache is expired
*/
export function isGuildCacheExpired(unixMs) {
return isCacheExpired(unixMs, credentials.cacheSeconds.guild);
}
/**
* Check if a bingo profile cache is expired based on the configured cache time
* @param {number} unixMs Unix timestamp in milliseconds
* @returns {boolean} Whether the cache is expired
*/
export function isBingoProfileCacheExpired(unixMs) {
return isCacheExpired(unixMs, credentials.cacheSeconds.bingoProfiles);
}